home *** CD-ROM | disk | FTP | other *** search
/ Winzipper / Winzipper_ISO.iso / programming / oracle7 7.2 / DB / UTIL72 / MIGRATE.BSQ < prev    next >
Encoding:
Text File  |  1995-05-09  |  158.1 KB  |  3,704 lines

  1. # $Header: migrate.bsq 7020200.1 95/02/15 18:37:46 cli Generic<base> $ 
  2. #  Copyright (c) 1991 by Oracle Corporation 
  3. #    NAME
  4. #      migrate.bsq - script for the migration utility
  5. #    NOTES
  6. #
  7. #      READ THIS IF YOU ARE CHANGING THIS FILE!!!!!!!!!!
  8. #
  9. #      1) Comments must be prefixed with #, *NOT* "Rem"
  10. #      2) This file runs under the V6 kernel, *NOT* V7.  So don't use
  11. #         V7 datatypes like VARCHAR2.
  12. #      3) If you add a new object, be sure to also add it to the V7_OBJECTS
  13. #         table, *AND* add a drop statement for it.  This script may be run
  14. #         multiple times under V6 before the user actually brings up V7.
  15. #
  16. #    MODIFIED   (MM/DD/YY)
  17. #     jstamos    11/30/94 -  merge changes from branch 1.40.710.17
  18. #     gpongrac   11/22/94 -  merge changes from branch 1.40.710.16; resync
  19. #     gpongrac   10/20/94 -  #244274; add I_ACCESS1, I_TRIGGERCOL, RESOURCE_MAP
  20. #     mramache   09/13/94 -  corrected column order on undo$ bootstrap entry
  21. #     bwadding   08/24/94 -  Fix updating of synonyms for DBlinks
  22. #     vraghuna   08/19/94 -  move export compatibility to catexp.sql
  23. #     jbellemo   06/23/94 -  TRUSTSP: add objpriv$
  24. #     gpongrac   06/24/94 -  merge changes from branch 1.40.710.14
  25. #     gpongrac   05/26/94 -  merge changes from branch 1.40.710.13
  26. #     vraghuna   04/08/94 -  merge changes from branch 1.40.710.10
  27. #     jbellemo   04/07/94 -  merge changes from branch 1.40.710.12
  28. #     gpongrac   04/07/94 -  merge changes from branch 1.40.710.11
  29. #     gpongrac   04/07/94 -  merge changes from branch 1.40.710.7
  30. #     gpongrac   04/07/94 -  merge changes from branch 1.40.710.5
  31. #     dleary     04/04/94 -  merge changes from branch 1.40.710.1
  32. #     rjenkins   03/09/94 -  merge changes from branch 1.40.710.8
  33. #     rjenkins   03/09/94 -  merge changes from branch 1.40.710.4
  34. #     rjenkins   01/19/94 -  merge changes from branch 1.40.710.3
  35. #     gpongrac   11/30/93 -  merge changes from branch 1.40.710.2
  36. #     gpongrac   06/07/94 -  #219765 populate ind$ after creating i_objauth1
  37. #     gpongrac   05/25/94 -  #208424: set maxextents back to 99 for sys rollb
  38. #     jbellemo   03/17/94 -  #206214: fix entries in stmt_audit_option_map
  39. #     gpongrac   02/15/94 -  #191563 drop TMPIDX before populating ind$
  40. #     vraghuna   02/10/94 -  replace expver$ with a row in props$
  41. #     vraghuna   02/07/94 -  add expver$ for versioning support
  42. #     rjenkins   02/07/94 -  adding unique index on rgroup
  43. #     gpongrac   02/07/94 -  move expact$, add it to v7_objects; drop jobseq$
  44. #     vraghuna   02/02/94 -  bug 191751 - add expact
  45. #     gpongrac   02/02/94 -  change Rem to #, remove varchar2 reference
  46. #     rjenkins   01/13/94 -  adding rollback seg col to rgroup$
  47. #     rjenkins   12/17/93 -  creating job queue
  48. #     gpongrac   11/30/93 -  merge changes from branch 1.25.312.8
  49. #     gpongrac   11/04/93 -  add comments about tmpidx; change objauth$ stuff
  50. #                 fix bug 188883 (pop obj$ after all objs created)
  51. #     dleary     10/26/93 -  add ora_tq_base$ sequence
  52. #     gpongrac   11/30/93 -  merge changes from branch 1.25.312.8
  53. #     dleary     10/26/93 -  add ora_tq_base$ sequence
  54. #     rjenkins   08/09/93 -  new snap$ columns for 7.1
  55. #     gpongrac   07/06/93 -  merge changes from branch 1.25.312.7
  56. #     gpongrac   07/02/93 -  change rem to #
  57. #     ajasuja    06/23/93 -  new rows into system_privilege_map
  58. #     jbellemo   06/14/93 -  #166465: change label column to raw(255)
  59. #     gpongrac   05/10/93 -  merge changes from branch 1.25.312.6 
  60. #     gpongrac   05/07/93 -  merge changes from branch 1.25.312.5 
  61. #     gpongrac   05/07/93 -  merge changes from branch 1.25.312.3 
  62. #     gpongrac   05/07/93 -  bug 159122 
  63. #     jbellemo   05/05/93 -  fix bogus  #'s 
  64. #     jbellemo   04/14/93 - #(158690) set defrole for PUBLIC 
  65. #     jbellemo   03/08/93 -  add SYSTEM GRANT back into audit_option table 
  66. #     jwijaya    03/05/93 -  merge changes from branch 1.25.312.2 
  67. #     jwijaya    03/04/93 -  merge changes from branch 1.25.312.1 
  68. #     jbellemo   02/22/93 -  remove SYSTEM GRANT and TRUNCATE as privs 
  69. #     aho        01/18/93 -  add semi-colons (bug 146865) 
  70. #     gpongrac   07/01/93 -  bug 155726 again; deal with nul val in col
  71. #     gpongrac   05/10/93 -  dont use concat operator 
  72. #     gpongrac   05/06/93 -  bug 159122 
  73. #     gpongrac   03/18/93 -  bug 155726; delete duplicate rows in objauth$
  74. #     jwijaya    03/03/93 -  fix a typo 
  75. #     jwijaya    03/01/93 -  idl_* changes 
  76. #     gpongrac   11/18/92 -  argument$ changes 
  77. #     ajasuja    11/18/92 -  merge changes from branch 1.16.311.3 
  78. #     gpongrac   11/13/92 -  change Rem to # 
  79. #     gpongrac   11/11/92 -  change lengths of char cols in argument$ 
  80. #     gpongrac   11/10/92 -  add rows for new MAP table indexes to v7_objects
  81. #     gpongrac   11/10/92 -  i_argument is a New object, not a Modified one 
  82. #     gpongrac   11/10/92 -  add argument$ table and sequence col to error$
  83. #     vraghuna   10/28/92 -  bug 130560 - move map tables into bsq 
  84. #     ajasuja    09/23/92 -  unique index on audit$ 
  85. #     gpongrac   09/10/92 -  prevent any space operations after we populate seg$
  86. #     gpongrac   09/09/92 -  set maxexts to 99 in the V7 catalog, not the V6
  87. #     gpongrac   09/08/92 -  improve objauth$ delete performance; bug 127869
  88. #     gpongrac   09/08/92 -  fix update of pctincrease for rollbacks to not sort
  89. #     gpongrac   09/08/92 -  bug 127942 - set default tablespace for migrate
  90. #     gpongrac   09/04/92 -  add dual to v7_objects as an 'N' type;
  91. #                            create c_file#_block# first so it gets the big xtnt
  92. #     gpongrac   09/03/92 -  account for c_file#_block# twice as big
  93. #     gpongrac   08/25/92 -  offline ts migration bug; drop maint.v7_objects 
  94. #     aho        08/24/92 -  use v7_objects table to swap sys & migrate 
  95. #     aho        08/17/92 -  rewrite sys/migrate swap (bg 124183) 
  96. #     alaursen   07/08/92 -  Move space computation 
  97. #     aho        07/07/92 -  more syntax silliness!
  98. #     aho        07/06/92 -  fix syntax errors 
  99. #     aho        06/29/92 -  drop junk from v6 and v5 before migration
  100. #                         -  (e.g. expvew, expvew5, catalog, catalog5, ulview)
  101. #     aho        06/24/92 -  add epeeler's changes for null constraints 
  102. #                         -  update comments in col$ and cdef$
  103. #     aho        06/02/92 -  remove duplicate grants in objauth (#110680) 
  104. #     aho        04/08/92 -  merge changes from branch 1.7.300.1 
  105. #     aho        04/07/92 -  enable not null constraints (103146 & 103233) 
  106. #     mmoore     02/19/92 -  add more privileges to the connect role 
  107. #     alaursen   01/27/92 -  add in space checking 
  108. #     alaursen   01/09/92 -  Fix PIDL types
  109. #     mmoore     12/13/91 -  new pidl tables,merge forward other changes
  110. #     aho        12/06/91 -  convert_nls() 
  111. #     alaursen   10/23/91 -  Add grant to dual 
  112. #     alaursen   10/16/91 -  Too many files under sys are moved to migrate 
  113. #     alaursen   10/06/91 -  Fix version number in bootstrap 
  114. #     alaursen   09/28/91 -  Creation 
  115. #^ connect (maint, internal)
  116. grant connect, resource, dba to migrate identified by migrate;
  117. alter user migrate default tablespace system;
  118. drop table dual;
  119. drop public synonym dual;
  120. drop table v7_objects;
  121. drop index tmpidx;
  122. #^ connect (migrate, migrate)
  123.  
  124. ##
  125. ## m_delete
  126. ##
  127.  
  128. drop table bootstrap$;
  129. drop cluster c_obj# including tables;
  130. drop cluster c_ts# including tables;
  131. drop cluster c_file#_block# including tables;
  132. drop cluster c_user# including tables;
  133. drop table undo$;
  134. drop table file$;
  135. drop table obj$;
  136. drop table con$;
  137. drop cluster c_cobj# including tables;
  138.  
  139. drop table syn$;
  140. drop table view$;
  141. drop table seq$;
  142. drop table procedure$;
  143. drop table argument$;
  144. drop table source$;
  145. drop table idl_ub1$;
  146. drop table idl_char$;
  147. drop table idl_ub2$;
  148. drop table idl_sb4$;
  149. drop table error$;
  150. drop table trigger$;
  151. drop table triggercol$;
  152. drop table objauth$;
  153. drop table sysauth$;
  154. drop table defrole$;
  155. drop table profile$;
  156. drop table profname$;
  157. drop table dependency$;
  158. drop table access$;
  159. drop table aud$;
  160. drop table lab$;
  161. drop table link$;
  162. drop table props$;
  163. drop table com$;
  164. drop table resource_cost$;
  165. drop sequence object_grant;
  166. drop sequence system_grant;
  167. drop sequence profnum$;
  168. drop table incexp;
  169. drop table expact$;
  170. drop table incvid;
  171. drop table incfil;
  172. drop table "_default_auditing_options_";
  173. drop sequence audses$;
  174. drop table audit$;
  175. drop table pending_trans$;
  176. drop table pending_sessions$;
  177. drop table pending_sub_sessions$;
  178. drop cluster c_mlog# including tables;
  179. drop table snap$;
  180. drop cluster c_rg# including tables;
  181. drop table job$;
  182. drop table duc$;
  183. drop cluster hist$ including tables;
  184. drop table dual;
  185. drop public synonym dual;
  186. drop sequence label_translation;
  187. drop table SYSTEM_PRIVILEGE_MAP;
  188. drop table TABLE_PRIVILEGE_MAP;
  189. drop table STMT_AUDIT_OPTION_MAP;
  190. drop sequence jobseq;
  191. drop sequence rgroupseq;
  192. drop sequence ora_tq_base$;
  193. drop table objpriv$;
  194.  
  195. ##
  196. ## create v7_objects table to enumerate how to migrate the v6 data dictionary
  197. ##
  198. #
  199. # L : leave this object alone.  it should be migrated from v6 to v7 in
  200. #     sys' schema unchanged.
  201. # M : migrate the object.  we will create an equivalent v7 in migrate's
  202. #     schema and then swap.  (the object exists in v6 and v7)
  203. # N : new object that did not exist in v6.  we need to check to make sure
  204. #     that the v6 sys schema does not contain the an object with the same
  205. #     name; it will change into the new v7 object without warning.
  206. # O : overlap.  if a type 'N' object exists in the v6 sys schema then
  207. #     it is changed into an 'O'.
  208. # P : purge.  this is an v6 object that no longer exists in v7.  it will
  209. #     disappear during the migration
  210. #
  211.  
  212. #^ connect (maint, internal)
  213.  
  214. create table v7_objects
  215. (
  216.  type   char(1),
  217.  name   char(30),
  218.  v6obj# number                             /* used by space calculation */
  219. );
  220.  
  221. create index i_v7_objects on v7_objects(v6obj#);
  222.  
  223. insert into v7_objects values ('P', 'V7_OBJECTS', -1);
  224. insert into v7_objects values ('N', 'ACCESS$', -1);
  225. insert into v7_objects values ('N', 'ARGUMENT$', -1);
  226. insert into v7_objects values ('M', 'AUD$', -1);
  227. insert into v7_objects values ('N', 'AUDIT$', -1);
  228. insert into v7_objects values ('L', 'AUDSES$', -1);
  229. insert into v7_objects values ('N', 'BOOTSTRAP$', -1);
  230. insert into v7_objects values ('M', 'CCOL$', -1);
  231. insert into v7_objects values ('M', 'CDEF$', -1);
  232. insert into v7_objects values ('M', 'CLU$', -1);
  233. insert into v7_objects values ('M', 'COL$', -1);
  234. insert into v7_objects values ('P', 'COLAUTH$', -1);
  235. insert into v7_objects values ('P', 'COLUMN_GRANT', -1);
  236. insert into v7_objects values ('M', 'COM$', -1);
  237. insert into v7_objects values ('M', 'CON$', -1);
  238. insert into v7_objects values ('M', 'C_COBJ#', -1);
  239. insert into v7_objects values ('M', 'C_FILE#_BLOCK#', -1);
  240. insert into v7_objects values ('N', 'C_MLOG#', -1);
  241. insert into v7_objects values ('M', 'C_OBJ#', -1);
  242. insert into v7_objects values ('N', 'C_RG#', -1);
  243. insert into v7_objects values ('M', 'C_TS#', -1);
  244. insert into v7_objects values ('M', 'C_USER#', -1);
  245. insert into v7_objects values ('N', 'DEFROLE$', -1);
  246. insert into v7_objects values ('N', 'DEPENDENCY$', -1);
  247. insert into v7_objects values ('N', 'DUAL', -1);
  248. insert into v7_objects values ('N', 'DUC$', -1);
  249. insert into v7_objects values ('N', 'ERROR$', -1);
  250. insert into v7_objects values ('N', 'EXPACT$', -1);
  251. insert into v7_objects values ('M', 'FET$', -1);
  252. insert into v7_objects values ('M', 'FILE$', -1);
  253. insert into v7_objects values ('N', 'HIST$', -1);
  254. insert into v7_objects values ('N', 'HISTOGRAM$', -1);
  255. insert into v7_objects values ('M', 'ICOL$', -1);
  256. insert into v7_objects values ('N', 'IDL_CHAR$', -1);
  257. insert into v7_objects values ('N', 'IDL_SB4$', -1);
  258. insert into v7_objects values ('N', 'IDL_UB1$', -1);
  259. insert into v7_objects values ('N', 'IDL_UB2$', -1);
  260. insert into v7_objects values ('M', 'INCEXP', -1);
  261. insert into v7_objects values ('M', 'INCFIL', -1);
  262. insert into v7_objects values ('M', 'INCVID', -1);
  263. insert into v7_objects values ('M', 'IND$', -1);
  264. insert into v7_objects values ('N', 'I_ACCESS1', -1);
  265. insert into v7_objects values ('M', 'I_AUD1', -1);
  266. insert into v7_objects values ('N', 'I_ARGUMENT1', -1);
  267. insert into v7_objects values ('N', 'I_AUDIT', -1);
  268. insert into v7_objects values ('M', 'I_CCOL1', -1);
  269. insert into v7_objects values ('M', 'I_CDEF1', -1);
  270. insert into v7_objects values ('M', 'I_CDEF2', -1);
  271. insert into v7_objects values ('N', 'I_CDEF3', -1);
  272. insert into v7_objects values ('M', 'I_COBJ#', -1);
  273. insert into v7_objects values ('M', 'I_COL1', -1);
  274. insert into v7_objects values ('M', 'I_COL2', -1);
  275. insert into v7_objects values ('P', 'I_COLAUTH1', -1);
  276. insert into v7_objects values ('P', 'I_COLAUTH2', -1);
  277. insert into v7_objects values ('P', 'I_COLAUTH3', -1);
  278. insert into v7_objects values ('M', 'I_COM1', -1);
  279. insert into v7_objects values ('M', 'I_CON1', -1);
  280. insert into v7_objects values ('M', 'I_CON2', -1);
  281. insert into v7_objects values ('N', 'I_DEFROLE1', -1);
  282. insert into v7_objects values ('N', 'I_DEPENDENCY1', -1);
  283. insert into v7_objects values ('N', 'I_DEPENDENCY2', -1);
  284. insert into v7_objects values ('N', 'I_DUC', -1);
  285. insert into v7_objects values ('N', 'I_ERROR1', -1);
  286. insert into v7_objects values ('M', 'I_FILE#_BLOCK#', -1);
  287. insert into v7_objects values ('M', 'I_FILE1', -1);
  288. insert into v7_objects values ('N', 'I_HIST$', -1);
  289. insert into v7_objects values ('M', 'I_ICOL1', -1);
  290. insert into v7_objects values ('N', 'I_IDL_CHAR1', -1);
  291. insert into v7_objects values ('N', 'I_IDL_SB41', -1);
  292. insert into v7_objects values ('N', 'I_IDL_UB11', -1);
  293. insert into v7_objects values ('N', 'I_IDL_UB21', -1);
  294. insert into v7_objects values ('M', 'I_INCEXP', -1);
  295. insert into v7_objects values ('M', 'I_IND1', -1);
  296. insert into v7_objects values ('N', 'I_JOB_JOB', -1);
  297. insert into v7_objects values ('N', 'I_JOB_NEXT', -1);
  298. insert into v7_objects values ('M', 'I_LINK1', -1);
  299. insert into v7_objects values ('N', 'I_MLOG#', -1);
  300. insert into v7_objects values ('M', 'I_OBJ#', -1);
  301. insert into v7_objects values ('M', 'I_OBJ1', -1);
  302. insert into v7_objects values ('M', 'I_OBJ2', -1);
  303. insert into v7_objects values ('N', 'I_OBJAUTH1', -1);
  304. insert into v7_objects values ('N', 'I_OBJAUTH2', -1);
  305. insert into v7_objects values ('N', 'I_PENDING_TRANS1', -1);
  306. insert into v7_objects values ('N', 'I_PROCEDURE1', -1);
  307. insert into v7_objects values ('N', 'I_PROFILE', -1);
  308. insert into v7_objects values ('N', 'I_PROFNAME', -1);
  309. insert into v7_objects values ('N', 'I_RG#', -1);
  310. insert into v7_objects values ('N', 'I_RGCHILD', -1);
  311. insert into v7_objects values ('N', 'I_RGJOB', -1);
  312. insert into v7_objects values ('N', 'I_RGREF', -1);
  313. insert into v7_objects values ('N', 'I_RGROUP', -1);
  314. insert into v7_objects values ('M', 'I_SEQ1', -1);
  315. insert into v7_objects values ('N', 'I_SLOG1', -1);
  316. insert into v7_objects values ('N', 'I_SNAP1', -1);
  317. insert into v7_objects values ('N', 'I_SOURCE1', -1);
  318. insert into v7_objects values ('N', 'I_STMT_AUDIT_OPTION_MAP', -1);
  319. insert into v7_objects values ('M', 'I_SYN1', -1);
  320. insert into v7_objects values ('N', 'I_SYSAUTH1', -1);
  321. insert into v7_objects values ('N', 'I_SYSTEM_PRIVILEGE_MAP', -1);
  322. insert into v7_objects values ('M', 'I_TAB1', -1);
  323. insert into v7_objects values ('P', 'I_TABAUTH1', -1);
  324. insert into v7_objects values ('P', 'I_TABAUTH2', -1);
  325. insert into v7_objects values ('N', 'I_TABLE_PRIVILEGE_MAP', -1);
  326. insert into v7_objects values ('N', 'I_TRIGGER1', -1);
  327. insert into v7_objects values ('N', 'I_TRIGGER2', -1);
  328. insert into v7_objects values ('N', 'I_TRIGGERCOL', -1);
  329. insert into v7_objects values ('M', 'I_TS#', -1);
  330. insert into v7_objects values ('M', 'I_UNDO1', -1);
  331. insert into v7_objects values ('M', 'I_USER#', -1);
  332. insert into v7_objects values ('M', 'I_USER1', -1);
  333. insert into v7_objects values ('M', 'I_VIEW1', -1);
  334. insert into v7_objects values ('P', 'I_V7_OBJECTS', -1);
  335. insert into v7_objects values ('P', 'I_XREF1', -1);
  336. insert into v7_objects values ('N', 'JOB$', -1);
  337. insert into v7_objects values ('N', 'JOBSEQ', -1);
  338. insert into v7_objects values ('N', 'LAB$', -1);
  339. insert into v7_objects values ('N', 'LABEL_TRANSLATION', -1);
  340. insert into v7_objects values ('M', 'LINK$', -1);
  341. insert into v7_objects values ('N', 'MLOG$', -1);
  342. insert into v7_objects values ('M', 'OBJ$', -1);
  343. insert into v7_objects values ('N', 'OBJAUTH$', -1);
  344. insert into v7_objects values ('N', 'OBJECT_GRANT', -1);
  345. insert into v7_objects values ('N', 'OBJPRIV$', -1);
  346. insert into v7_objects values ('N', 'ORA_TQ_BASE$', -1);
  347. insert into v7_objects values ('N', 'PENDING_SESSIONS$', -1);
  348. insert into v7_objects values ('N', 'PENDING_SUB_SESSIONS$', -1);
  349. insert into v7_objects values ('N', 'PENDING_TRANS$', -1);
  350. insert into v7_objects values ('N', 'PROCEDURE$', -1);
  351. insert into v7_objects values ('N', 'PROFILE$', -1);
  352. insert into v7_objects values ('N', 'PROFNAME$', -1);
  353. insert into v7_objects values ('N', 'PROFNUM$', -1);
  354. insert into v7_objects values ('M', 'PROPS$', -1);
  355. insert into v7_objects values ('N', 'RESOURCE_COST$', -1);
  356. insert into v7_objects values ('N', 'RESOURCE_MAP', -1);
  357. insert into v7_objects values ('N', 'RGCHILD$', -1);
  358. insert into v7_objects values ('N', 'RGROUP$', -1);
  359. insert into v7_objects values ('N', 'RGROUPSEQ', -1);
  360. insert into v7_objects values ('M', 'SEG$', -1);
  361. insert into v7_objects values ('M', 'SEQ$', -1);
  362. insert into v7_objects values ('N', 'SLOG$', -1);
  363. insert into v7_objects values ('N', 'SNAP$', -1);
  364. insert into v7_objects values ('N', 'SOURCE$', -1);
  365. insert into v7_objects values ('N', 'STMT_AUDIT_OPTION_MAP', -1);
  366. insert into v7_objects values ('M', 'SYN$', -1);
  367. insert into v7_objects values ('N', 'SYSAUTH$', -1);
  368. insert into v7_objects values ('N', 'SYSTEM_GRANT', -1);
  369. insert into v7_objects values ('N', 'SYSTEM_PRIVILEGE_MAP', -1);
  370. insert into v7_objects values ('M', 'TAB$', -1);
  371. insert into v7_objects values ('P', 'TABAUTH$', -1);
  372. insert into v7_objects values ('P', 'TABLE_GRANT', -1);
  373. insert into v7_objects values ('N', 'TABLE_PRIVILEGE_MAP', -1);
  374. insert into v7_objects values ('N', 'TRIGGER$', -1);
  375. insert into v7_objects values ('N', 'TRIGGERCOL$', -1);
  376. insert into v7_objects values ('M', 'TS$', -1);
  377. insert into v7_objects values ('M', 'TSQ$', -1);
  378. insert into v7_objects values ('M', 'UET$', -1);
  379. insert into v7_objects values ('M', 'UNDO$', -1);
  380. insert into v7_objects values ('M', 'USER$', -1);
  381. insert into v7_objects values ('M', 'VIEW$', -1);
  382. insert into v7_objects values ('P', 'XREF$', -1);
  383. insert into v7_objects values ('L', '_NEXT_OBJECT', -1);
  384. insert into v7_objects values ('M', '_default_auditing_options_', -1);
  385. insert into v7_objects values ('P', '_system_auditing_options_', -1);
  386.  
  387. update v7_objects set type = 'O' 
  388.    where type = 'N' and
  389.          name in (select name from obj$ 
  390.                   where owner# = (select user# from user$ 
  391.                                   where name = 'SYS'));
  392.  
  393. update v7_objects x set v6obj# =
  394.     (select obj# from obj$ y
  395.      where x.name = y.name
  396.       and  y.owner# =
  397.         (select user# from user$ where name = 'SYS'))
  398.      where type <> 'N' and type <> 'P';
  399.  
  400. ##
  401. ## m_space
  402. ##
  403. ## is there enough space?
  404. ##
  405. #^ space_fb()
  406. #^ connect (migrate, migrate)
  407. #^ create_cluster_fb()
  408. #^ connect (maint,internal)
  409. #^ space_ts()
  410. #^ connect (migrate, migrate)
  411. #^ create_cluster_ts()
  412. #^ connect (maint, internal)
  413. #^ space_out()
  414.  
  415. ##
  416. ## m_catalog
  417. ##
  418. ## remove v6 and v5 views and catalogs
  419. ## don't remove the table dual!
  420. ##
  421.  
  422. #
  423. # expvew.sql
  424. #
  425. drop view exutab;
  426. drop view exutabi;
  427. drop view exutabc;
  428. drop view exutabu;
  429. drop view exucol;
  430. drop view exucolu;
  431. drop view exuico;
  432. drop view exuicou;
  433. drop view exuusr;
  434. drop view exuusru;
  435. drop view exugrn;
  436. drop view exugrnu;
  437. drop view exucgr;
  438. drop view exucgru;
  439. drop view exuind;
  440. drop view exuindu;
  441. drop view exuvew;
  442. drop view exuvewi;
  443. drop view exuvewc;
  444. drop view exuvewu;
  445. drop view exusyn;
  446. drop view exusyni;
  447. drop view exusync;
  448. drop view exusynu;
  449. drop view exucco;
  450. drop view exuccou;
  451. drop view exuclu;
  452. drop view exuclui;
  453. drop view exucluc;
  454. drop view exucluu;
  455. drop view exusto;
  456. drop view exustou;
  457. drop view exutbs;
  458. drop view exutsq;
  459. drop view exubsz;
  460. drop view exufil;
  461. drop view exulnk;
  462. drop view exulnku;
  463. drop view exursg;
  464. drop view exudel;
  465. drop view exuseq;
  466. drop view exusequ;
  467. drop view exucon;
  468. drop view exuconu;
  469. drop view exuref;
  470. drop view exurefu;
  471. drop view exurefic;
  472. drop view exurefi;
  473. drop view exurefc;
  474. drop view exuccl;
  475. drop view exucclu;
  476. drop view exucclo;
  477. drop view exurep;
  478. drop view exurepu;
  479. drop view exurepic;
  480. drop view exurepi;
  481. drop view exurepc;
  482. #
  483. # expvew5.sql
  484. #
  485. drop view tables;
  486. drop view columns;
  487. drop view extents;
  488. drop table tabauth;
  489. drop view views;
  490. drop table spaces;
  491. drop view indexes;
  492. drop view userauth;
  493. drop view partitions;
  494. drop view segquotas;
  495. drop view v4expuser;
  496. drop view v4expspace;
  497. drop view v4expindex;
  498. drop view v4exptab;
  499. drop view v4expclus;
  500. drop view v4exptabauth;
  501. drop view v4expextents;
  502. drop view v4expcol;
  503. drop view v4expsyn;
  504. drop view v4expview;
  505. #
  506. # catalog.sql
  507. #
  508. drop table AUDIT_ACTIONS;
  509. drop public synonym AUDIT_ACTIONS;
  510. drop view USER_AUDIT_TRAIL;
  511. drop public synonym USER_AUDIT_TRAIL;
  512. drop public synonym DBA_AUDIT_TRAIL;
  513. drop view USER_AUDIT_CONNECT;
  514. drop public synonym USER_AUDIT_CONNECT;
  515. drop public synonym DBA_AUDIT_CONNECT;
  516. drop view DBA_AUDIT_EXISTS;
  517. drop public synonym DBA_AUDIT_EXISTS;
  518. drop view USER_AUDIT_RESOURCE;
  519. drop public synonym USER_AUDIT_RESOURCE;
  520. drop public synonym DBA_AUDIT_RESOURCE;
  521. drop view DBA_AUDIT_DBA;
  522. drop public synonym DBA_AUDIT_DBA;
  523. drop view USER_CATALOG;
  524. drop public synonym USER_CATALOG;
  525. drop public synonym CAT;
  526. drop view ALL_CATALOG;
  527. drop public synonym ALL_CATALOG;
  528. drop view ACCESSIBLE_TABLES;
  529. drop public synonym ACCESSIBLE_TABLES;
  530. drop view DBA_CATALOG;
  531. drop view USER_CLUSTERS;
  532. drop public synonym USER_CLUSTERS;
  533. drop public synonym CLU;
  534. drop view DBA_CLUSTERS;
  535. drop view USER_CLU_COLUMNS;
  536. drop public synonym USER_CLU_COLUMNS;
  537. drop view DBA_CLU_COLUMNS;
  538. drop view USER_COL_COMMENTS;
  539. drop public synonym USER_COL_COMMENTS;
  540. drop view ALL_COL_COMMENTS;
  541. drop public synonym ALL_COL_COMMENTS;
  542. drop view DBA_COL_COMMENTS;
  543. drop view USER_COL_GRANTS;
  544. drop public synonym USER_COL_GRANTS;
  545. drop view COLUMN_PRIVILEGES;
  546. drop public synonym COLUMN_PRIVILEGES;
  547. drop public synonym ALL_COL_GRANTS;
  548. drop view DBA_COL_GRANTS;
  549. drop view USER_COL_GRANTS_MADE;
  550. drop public synonym USER_COL_GRANTS_MADE;
  551. drop view ALL_COL_GRANTS_MADE;
  552. drop public synonym ALL_COL_GRANTS_MADE;
  553. drop view USER_COL_GRANTS_RECD;
  554. drop public synonym USER_COL_GRANTS_RECD;
  555. drop view ALL_COL_GRANTS_RECD;
  556. drop public synonym ALL_COL_GRANTS_RECD;
  557. drop view USER_CROSS_REFS;
  558. drop public synonym USER_CROSS_REFS;
  559. drop view DBA_CROSS_REFS;
  560. drop view DBA_DATA_FILES;
  561. drop view USER_DB_LINKS;
  562. drop public synonym USER_DB_LINKS;
  563. drop view ALL_DB_LINKS;
  564. drop public synonym ALL_DB_LINKS;
  565. drop view DBA_DB_LINKS;
  566. drop view ALL_DEF_AUDIT_OPTS;
  567. drop public synonym ALL_DEF_AUDIT_OPTS;
  568. drop view DICTIONARY;
  569. drop public synonym DICTIONARY;
  570. drop public synonym DICT;
  571. drop view DICT_COLUMNS;
  572. drop public synonym DICT_COLUMNS;
  573. drop view DBA_EXP_OBJECTS;
  574. drop view DBA_EXP_VERSION;
  575. drop view DBA_EXP_FILES;
  576. drop view USER_FREE_SPACE;
  577. drop public synonym USER_FREE_SPACE;
  578. drop view DBA_FREE_SPACE;
  579. drop view USER_INDEXES;
  580. drop public synonym USER_INDEXES;
  581. drop public synonym IND;
  582. drop view ALL_INDEXES;
  583. drop public synonym ALL_INDEXES;
  584. drop view DBA_INDEXES;
  585. drop view USER_IND_COLUMNS;
  586. drop public synonym USER_IND_COLUMNS;
  587. drop view ALL_IND_COLUMNS;
  588. drop public synonym ALL_IND_COLUMNS;
  589. drop view DBA_IND_COLUMNS;
  590. drop view INDEX_STATS;
  591. drop public synonym INDEX_STATS;
  592. drop view INDEX_HISTOGRAM;
  593. drop public synonym INDEX_HISTOGRAM;
  594. drop view USER_OBJECTS;
  595. drop public synonym USER_OBJECTS;
  596. drop public synonym OBJ;
  597. drop view ALL_OBJECTS;
  598. drop public synonym ALL_OBJECTS;
  599. drop view DBA_OBJECTS;
  600. drop view DBA_ROLLBACK_SEGS;
  601. drop view SYS_OBJECTS;
  602. drop view USER_SEGMENTS;
  603. drop public synonym USER_SEGMENTS;
  604. drop view DBA_SEGMENTS;
  605. drop view USER_EXTENTS;
  606. drop public synonym USER_EXTENTS;
  607. drop view DBA_EXTENTS;
  608. drop view USER_SEQUENCES;
  609. drop public synonym USER_SEQUENCES;
  610. drop public synonym SEQ;
  611. drop view ALL_SEQUENCES;
  612. drop public synonym ALL_SEQUENCES;
  613. drop view DBA_SEQUENCES;
  614. drop view USER_SYNONYMS;
  615. drop public synonym SYN;
  616. drop public synonym USER_SYNONYMS;
  617. drop view ALL_SYNONYMS;
  618. drop public synonym ALL_SYNONYMS;
  619. drop view DBA_SYNONYMS;
  620. drop view DBA_SYS_AUDIT_OPTS;
  621. drop view USER_TABLES;
  622. drop public synonym USER_TABLES;
  623. drop public synonym TABS;
  624. drop view ALL_TABLES;
  625. drop public synonym ALL_TABLES;
  626. drop view DBA_TABLES;
  627. drop view USER_TABLESPACES;
  628. drop public synonym USER_TABLESPACES;
  629. drop view DBA_TABLESPACES;
  630. drop view USER_TAB_AUDIT_OPTS;
  631. drop public synonym USER_TAB_AUDIT_OPTS;
  632. drop view DBA_TAB_AUDIT_OPTS;
  633. drop view USER_TAB_COLUMNS;
  634. drop public synonym USER_TAB_COLUMNS;
  635. drop public synonym COLS;
  636. drop view ACCESSIBLE_COLUMNS;
  637. drop public synonym ACCESSIBLE_COLUMNS;
  638. drop public synonym ALL_TAB_COLUMNS;
  639. drop view DBA_TAB_COLUMNS;
  640. drop view USER_TAB_COMMENTS;
  641. drop public synonym USER_TAB_COMMENTS;
  642. drop view ALL_TAB_COMMENTS;
  643. drop public synonym ALL_TAB_COMMENTS;
  644. drop view DBA_TAB_COMMENTS;
  645. drop view USER_TAB_GRANTS;
  646. drop public synonym USER_TAB_GRANTS;
  647. drop view TABLE_PRIVILEGES;
  648. drop public synonym TABLE_PRIVILEGES;
  649. drop public synonym ALL_TAB_GRANTS;
  650. drop view DBA_TAB_GRANTS;
  651. drop view USER_TAB_GRANTS_MADE;
  652. drop public synonym USER_TAB_GRANTS_MADE;
  653. drop view ALL_TAB_GRANTS_MADE;
  654. drop public synonym ALL_TAB_GRANTS_MADE;
  655. drop view USER_TAB_GRANTS_RECD;
  656. drop public synonym USER_TAB_GRANTS_RECD;
  657. drop view ALL_TAB_GRANTS_RECD;
  658. drop public synonym ALL_TAB_GRANTS_RECD;
  659. drop view USER_TS_QUOTAS;
  660. drop public synonym USER_TS_QUOTAS;
  661. drop view DBA_TS_QUOTAS;
  662. drop view USER_USERS;
  663. drop public synonym USER_USERS;
  664. drop public synonym MYPRIVS;
  665. drop view ALL_USERS;
  666. drop public synonym ALL_USERS;
  667. drop view DBA_USERS;
  668. drop view USER_VIEWS;
  669. drop public synonym USER_VIEWS;
  670. drop view ALL_VIEWS;
  671. drop public synonym ALL_VIEWS;
  672. drop view DBA_VIEWS;
  673. drop view USER_CONSTRAINTS;
  674. drop public synonym USER_CONSTRAINTS;
  675. drop view ALL_CONSTRAINTS;
  676. drop public synonym ALL_CONSTRAINTS;
  677. drop view DBA_CONSTRAINTS;
  678. drop public synonym DBA_CONSTRAINTS;
  679. drop view USER_CONS_COLUMNS;
  680. drop public synonym USER_CONS_COLUMNS;
  681. drop view ALL_CONS_COLUMNS;
  682. drop public synonym ALL_CONS_COLUMNS;
  683. drop view DBA_CONS_COLUMNS;
  684. drop public synonym DBA_CONS_COLUMNS;
  685. drop view CONSTRAINT_DEFS;
  686. drop public synonym CONSTRAINT_DEFS;
  687. drop view CONSTRAINT_COLUMNS;
  688. drop public synonym CONSTRAINT_COLUMNS;
  689. drop view v_$waitstat;
  690. drop public synonym v$waitstat;
  691. drop view v_$process;
  692. drop public synonym v$process;
  693. drop view v_$bgprocess;
  694. drop public synonym v$bgprocess;
  695. drop view v_$session;
  696. drop public synonym v$session;
  697. drop view v_$transaction;
  698. drop public synonym v$transaction;
  699. drop view v_$latch;
  700. drop public synonym v$latch;
  701. drop view v_$latchname;
  702. drop public synonym v$latchname;
  703. drop view v_$latchholder;
  704. drop public synonym v$latchholder;
  705. drop view v_$resource;
  706. drop public synonym v$resource;
  707. drop view v_$_lock;
  708. drop public synonym v$_lock;
  709. drop view v_$lock;
  710. drop public synonym v$lock;
  711. drop view v_$sesstat;
  712. drop public synonym v$sesstat;
  713. drop view v_$sysstat;
  714. drop public synonym v$sysstat;
  715. drop view v_$statname;
  716. drop public synonym v$statname;
  717. drop view v_$access;
  718. drop public synonym v$access;
  719. drop view v_$dbfile;
  720. drop public synonym v$dbfile;
  721. drop view v_$filestat;
  722. drop public synonym v$filestat;
  723. drop view v_$logfile;
  724. drop public synonym v$logfile;
  725. drop view v_$rollname;
  726. drop public synonym v$rollname;
  727. drop view v_$rollstat;
  728. drop public synonym v$rollstat;
  729. drop view v_$sga;
  730. drop public synonym v$sga;
  731. drop view v_$parameter;
  732. drop public synonym v$parameter;
  733. drop view v_$rowcache;
  734. drop public synonym v$rowcache;
  735. drop view syscatalog_;
  736. drop view syscatalog;
  737. drop view catalog;
  738. drop view tab;
  739. drop view col;
  740. drop view syssegobj;
  741. drop view tabquotas;
  742. drop view sysfiles;
  743. drop view synonyms;
  744. drop view publicsyn;
  745. #
  746. # catalog5.sql
  747. #
  748. drop view systaballoc_;
  749. drop view systaballoc;
  750. drop view taballoc;
  751. drop view syssegobj;
  752. drop view sysstorage_;
  753. drop view sysstorage;
  754. drop view freespace;
  755. drop view storage;
  756. drop view sysextents_;
  757. drop view sysextents;
  758. drop view extents;
  759. drop view syscolumns_;
  760. drop view syscolumns;
  761. drop view columns;
  762. drop view syscatalog_;
  763. drop view syscatalog;
  764. drop view catalog;
  765. drop view sysindexes_;
  766. drop view sysindexes;
  767. drop view indexes;
  768. drop view clusters;
  769. drop view clustercolumns;
  770. drop view views;
  771. drop view sysviews;
  772. drop view systabauth;
  773. drop view syscolauth;
  774. drop view sysuserauth;
  775. drop view sysuserlist;
  776. drop view synonyms;
  777. drop view publicsyn;
  778. drop view privatesyn;
  779. drop view tab;
  780. drop view col;
  781. drop view tabquotas;
  782. drop view SYSTEM_AUDIT;
  783. drop view DEFAULT_AUDIT;
  784. drop view TABLE_AUDIT;
  785. drop table audit_actions;
  786. drop view audit_trail;
  787. drop view AUDIT_DBA;
  788. drop view AUDIT_EXISTS;
  789. drop view AUDIT_CONNECT;
  790. drop view SESSIONS;
  791. drop view AUDIT_ACCESS;
  792. drop view dblinks;
  793. drop view sysdblinks;
  794. drop view systabspaces;
  795. drop view tabspaces;
  796. drop view sysfiles;
  797. drop view systsquotas_;
  798. drop view systsquotas;
  799. drop view tsquotas;
  800. drop view sysrollbackseg;
  801. drop table dtab;
  802. #
  803. # ulview.sql
  804. #
  805. drop view LOADER_COL_INFO;
  806. drop public synonym LOADER_COL_INFO;
  807. drop view LOADER_TAB_INFO;
  808. drop public synonym LOADER_TAB_INFO;
  809. drop view LOADER_IND_INFO;
  810. drop public synonym LOADER_IND_INFO;
  811. drop view LOADER_INDCOL_INFO;
  812. drop public synonym LOADER_INDCOL_INFO;
  813. drop view LOADER_PARAM_INFO;
  814. drop public synonym LOADER_PARAM_INFO;
  815. drop view v_$loadcstat;
  816. drop public synonym v$loadcstat;
  817. drop view v_$loadtstat;
  818. drop public synonym v$loadtstat;
  819.  
  820. #^ connect (migrate, migrate)
  821.  
  822. #
  823. # m_sqlbsq
  824. #
  825.  
  826. create cluster c_obj# (obj# number)
  827.   pctfree 5 size 800                           /* don't waste too much space */
  828.   /* A table of 32 cols, 2 index, 2 col per index requires about 2K.
  829.    * A table of 10 cols, 2 index, 2 col per index requires about 750.
  830.    */
  831.   storage (initial 120K)              /* avoid space management during IOR I */
  832. /
  833. create index i_obj# on cluster c_obj#
  834. /
  835. create table tab$                                             /* table table */
  836. ( obj#             number not null,                            /* object number */
  837.   ts#        number not null,                        /* tablespace number */
  838.   file#        number not null,               /* segment header file number */
  839.   block#    number not null,              /* segment header block number */
  840.   clu#          number,      /* cluster object number, NULL if not clustered */
  841.   tab#        number,    /* table number in cluster, NULL if not clustered */
  842.   cols          number not null,            /* number of columns */
  843.   clucols       number,/* number of clustered columns, NULL if not clustered */
  844.   pctfree$      number not null, /* minimum free space percentage in a block */
  845.   pctused$      number not null, /* minimum used space percentage in a block */
  846.   initrans      number not null,            /* initial number of transaction */
  847.   maxtrans      number not null,            /* maximum number of transaction */
  848.   modified      number not null,                               /* dirty bit: */
  849.                 /* 0 = unmodified since last backup, 1 = modified since then */
  850.   audit$    char("S_OPFL") not null,             /* auditing options */
  851.   rowcnt        number,                                    /* number of rows */
  852.   blkcnt        number,                                  /* number of blocks */
  853.   empcnt        number,                            /* number of empty blocks */
  854.   avgspc        number,                      /* average available free space */
  855.   chncnt        number,                            /* number of chained rows */
  856.   avgrln        number,                                /* average row length */
  857.   spare1        number,
  858.   spare2        number)
  859. cluster c_obj#(obj#)
  860. /  
  861. create table clu$                        /* cluster table */
  862. ( obj#         number not null,                            /* object number */
  863.   ts#        number not null,                        /* tablespace number */
  864.   file#        number not null,               /* segment header file number */
  865.   block#    number not null,              /* segment header block number */
  866.   cols          number not null,            /* number of columns */
  867.   pctfree$      number not null, /* minimum free space percentage in a block */
  868.   pctused$      number not null, /* minimum used space percentage in a block */
  869.   initrans      number not null,            /* initial number of transaction */
  870.   maxtrans      number not null,            /* maximum number of transaction */
  871.   size$         number,
  872.        /* if b-tree, estimated number of bytes for each cluster key and rows */
  873.   hashfunc      char("M_IDEN"),        /* if hashed, function identifier */
  874.  
  875.   /* Some of the spare columns may give the initial # bytes in the hash table
  876.    * and the # hash keys per block.  These are user-specified parameters.
  877.    * For extendible hash tables, two columns might include the # bits
  878.    * currently be used in the hash function and the number of the next
  879.    * bucket to split.
  880.    * Some spare columns may be used for hash table statistics
  881.    * such as # distinct keys, # distinct values of first key column, and
  882.    * average # blocks per key.  Some spare columns  may give the number of
  883.    * the cluster table for which the cluster key is unique or indicate
  884.    * whether the cluster is normal or referential.
  885.    * We can encode multiple pieces of info in a single column.
  886.    */
  887.   hashkeys      number,                                    /* hash key count */
  888.   func          number, /* function: 0 (key is function), 1 (system default) */
  889.   extind        number,             /* extent index value of fixed hash area */
  890.   spare4        number,
  891.   spare5        number,
  892.   spare6        number,
  893.   spare7        number,
  894.   spare8        number,
  895.   spare9        number
  896. )
  897. cluster c_obj#(obj#)
  898. /
  899. create cluster c_user#(user# number) 
  900.   size  315 /* cluster key ~ 20, sizeof(user$) ~ 170, 5 * sizeof(tsq$) ~ 125 */
  901. /
  902. create index i_user# on cluster c_user#
  903. /
  904. create table fet$                                       /* free extent table */
  905. ( ts#           number not null,        /* tablespace containing free extent */
  906.   file#         number not null,              /* file containing free extent */
  907.   block#        number not null,              /* starting dba of free extent */
  908.   length        number not null)          /* length in blocks of free extent */
  909. cluster c_ts#(ts#)
  910. /
  911. create table undo$                                     /* undo segment table */
  912. ( us#           number not null,                      /* undo segment number */
  913.   name          char("M_IDEN") not null,    /* name of this undo segment */
  914.   user#         number not null,      /* owner: 0 = SYS(PRIVATE), 1 = PUBLIC */
  915.   file#         number not null,               /* segment header file number */
  916.   block#        number not null,              /* segment header block number */
  917.   scnbas        number,           /* highest commit time in rollback segment */
  918.   scnwrp        number,              /* scnbas - scn base, scnwrp - scn wrap */
  919.   xactsqn       number,               /* highest transaction sequence number */
  920.   undosqn       number,                /* highest undo block sequence number */
  921.   inst#         number,    /* parallel server instance that owns the segment */
  922.   status$       number not null)              /* segment status (see KTS.H): */
  923.     /* 1 = INVALID, 2 = AVAILABLE, 3 = IN USE, 4 = OFFLINE 5 = NEED RECOVERY */
  924. /
  925. create table ts$                                         /* tablespace table */
  926. ( ts#           number not null,             /* tablespace identifier number */
  927.   name          char("M_IDEN") not null,           /* name of tablespace */
  928.   owner#        number not null,                      /* owner of tablespace */
  929.   online$       number not null,                      /* status (see KTT.H): */
  930.                                      /* 1 = ONLINE, 2 = OFFLINE, 3 = INVALID */
  931.   undofile#     number,  /* undo_off segment file number (status is OFFLINE) */
  932.   undoblock#    number,               /* undo_off segment header file number */
  933.   blocksize     number not null,                   /* size of block in bytes */
  934.   inc#          number not null,             /* incarnation number of extent */
  935.   scnwrp    number,     /* clean offline scn - zero if not offline clean */
  936.   scnbas        number,              /* scnbas - scn base, scnwrp - scn wrap */
  937.   dflminext     number not null,       /*  default minimum number of extents */
  938.   dflmaxext     number not null,        /* default maximum number of extents */
  939.   dflinit       number not null,              /* default initial extent size */
  940.   dflincr       number not null,                 /* default next extent size */
  941.   dflextpct     number not null)     /* default percent extent size increase */
  942. cluster c_ts#(ts#)
  943. /
  944. create table file$                                             /* file table */
  945. ( file#         number not null,                   /* file identifier number */
  946.   status$       number not null,                      /* status (see KTS.H): */
  947.                                                /* 1 = INVALID, 2 = AVAILABLE */
  948.   blocks        number not null,                   /* size of file in blocks */
  949.   ts#           number not null)                /* tablespace that owns file */
  950. /
  951. create table obj$                                            /* object table */
  952. ( obj#          number not null,                            /* object number */
  953.   owner#        number not null,                        /* owner user number */
  954.   name        char("M_IDEN") not null,              /* object name */
  955.   namespace     number not null,         /* namespace of object (see KQD.H): */
  956.        /* 1 = TABLE/PROCEDURE, 2 = BODY, 3 = TRIGGER, 4 = INDEX, 5 = CLUSTER */
  957.   type          number not null,                 /* object type (see KQD.H): */
  958.   /* 1 = INDEX, 2 = TABLE, 3 = CLUSTER, 4 = VIEW, 5 = SYNONYM, 6 = SEQUENCE, */
  959.              /* 7 = PROCEDURE, 8 = FUNCTION, 9 = PACKAGE, 10 = NON-EXISTENT, */
  960.                                           /* 11 = PACKAGE BODY, 12 = TRIGGER */
  961.   ctime        date not null,                       /* object creation time */
  962.   mtime        date not null,                      /* DDL modification time */
  963.   stime        date not null,          /* specification timestamp (version) */
  964.   status        number not null,            /* status of object (see KQD.H): */
  965.                                      /* 1 = VALID/AUTHORIZED WITHOUT ERRORS, */
  966.                           /* 2 = VALID/AUTHORIZED WITH AUTHORIZATION ERRORS, */
  967.                             /* 3 = VALID/AUTHORIZED WITH COMPILATION ERRORS, */
  968.                          /* 4 = VALID/UNAUTHORIZED, 5 = INVALID/UNAUTHORIZED */
  969.   remoteowner   char("M_IDEN"),    /* remote owner name (remote object) */
  970.   linkname      char("M_XDBI"))            /* link name (remote object) */
  971. /
  972. create table ind$                                             /* index table */
  973. ( obj#          number not null,                /* object number */
  974.   ts#        number not null,                        /* tablespace number */
  975.   file#        number not null,               /* segment header file number */
  976.   block#    number not null,              /* segment header block number */
  977.   bo#        number not null,          /* object number of base table */
  978.   cols          number not null,            /* number of columns */
  979.   pctfree$      number not null, /* minimum free space percentage in a block */
  980.   initrans      number not null,            /* initial number of transaction */
  981.   maxtrans      number not null,            /* maximum number of transaction */
  982.   compress$     number not null,       /* 0 = not compressed, 1 = compressed */
  983.   unique$       number not null,               /* 0 = not unique, 1 = unique */
  984.                                             /* future: 2 = ansi-style unique */
  985.   /* The following spare columns may be used for index statistics such
  986.    * as # btree levels, # btree leaf blocks, # distinct keys, 
  987.    * # distinct values of first key column, average # leaf blocks per key,
  988.    * clustering info, and # blocks in index segment.
  989.    */
  990.   blevel        number,                                       /* btree level */
  991.   leafcnt       number,                                  /* # of leaf blocks */
  992.   distkey       number,                                   /* # distinct keys */
  993.   lblkkey       number,                          /* avg # of leaf blocks/key */
  994.   dblkkey       number,                          /* avg # of data blocks/key */
  995.   clufac        number,                                 /* clustering factor */
  996.   spare7        number,
  997.   spare8        number)
  998. cluster c_obj#(bo#)
  999. /
  1000. create table icol$                                     /* index column table */
  1001. ( obj#          number not null,                      /* index object number */
  1002.   bo#           number not null,               /* base object number */
  1003.   col#          number not null,                            /* column number */
  1004.   pos#          number not null,        /* column position number as created */
  1005.   segcol#       number not null,         /* column number in segment */
  1006.   segcollength  number not null,             /* length of the segment column */
  1007.   offset        number not null)                         /* offset of column */
  1008. cluster c_obj#(bo#)
  1009. /
  1010. create table col$                                            /* column table */
  1011. ( obj#          number not null,             /* object number of base object */
  1012.   col#        number not null,                 /* column number as created */
  1013.   segcol#    number not null,         /* column number in segment */
  1014.   segcollength  number not null,             /* length of the segment column */
  1015.   offset        number not null,                         /* offset of column */
  1016.   name        char("M_IDEN") not null,           /* name of column */
  1017.   type#          number  not null,              /* data type of column */
  1018.   length    number  not null,        /* length of column in bytes */
  1019.   fixedstorage  number  not null,                /* 0 = not fixed, 1 = fixed */
  1020.   precision     number,                                         /* precision */
  1021.   scale         number,                                             /* scale */
  1022.   null$         number not null,                     /* 0 = NULLs permitted, */
  1023.                                                 /* > 0 = no NULLs permitted  */
  1024.   distcnt       number,                              /* # of distinct values */
  1025.   lowval        raw(32),/* lowest value of column (second lowest if default) */
  1026.   hival         raw(32),
  1027.                       /* highest value of column (second highest if default) */
  1028.   deflength     number,              /* default value expression text length */
  1029.   default$      long,                       /* default value expression text */
  1030.   /* The spares may be used as the column's NLS character set, 
  1031.    * the number of distinct column values, and the column's domain.
  1032.    */
  1033.   spare2        number,
  1034.   spare3        number)
  1035. cluster c_obj#(obj#)
  1036. /
  1037. create table user$                                             /* user table */
  1038. ( user#        number not null,                   /* user identifier number */
  1039.   name            char("M_IDEN") not null,             /* name of user */
  1040.   type          number not null,                       /* 0 = role, 1 = user */
  1041.   password    char("M_IDEN"),               /* encrypted password */
  1042.   datats#         number not null, /* default tablespace for permanent objects */
  1043.   tempts#         number not null,  /* default tablespace for temporary tables */
  1044.   ctime         date not null,                 /* user account creation time */
  1045.   ptime         date,                            /* password expiration time */
  1046.   resource$     number not null,                        /* resource profile# */
  1047.   audit$    char("S_OPFL"),                     /* user audit options */
  1048.   defrole       number not null,                  /* default role indicator: */
  1049.                /* 0 = no roles, 1 = all roles granted, 2 = roles in defrole$ */
  1050.   spare1        number,                               /* reserved for future */
  1051.   spare2        number)                               /* reserved for future */
  1052. cluster c_user#(user#)
  1053. /
  1054. create table con$                                        /* constraint table */
  1055. ( owner#        number not null,                        /* owner user number */
  1056.   name          char("M_IDEN") not null,                  /* constraint name */
  1057.   con#          number not null,                        /* constraint number */
  1058.   spare1        number)
  1059. /
  1060. create cluster c_cobj# (obj# number)
  1061.   pctfree 0 pctused 50
  1062.   /* space for: update cdef$ set condition = 'col IS NOT NULL' at // */
  1063.   size 300
  1064.   storage (initial 50K)               /* avoid space management during IOR I */
  1065. /
  1066. create index i_cobj# on cluster c_cobj#
  1067. /
  1068. create table cdef$                            /* constraint definition table */
  1069. ( con#          number not null,                        /* constraint number */
  1070.   obj#          number not null,         /* object number of base table/view */
  1071.   cols          number,                   /* number of columns in constraint */
  1072.   type          number not null,                         /* constraint type: */
  1073.                             /* 1 = table check, 2 = primary key, 3 = unique, */
  1074.                                          /* 4 = referential, 5 = view check, */
  1075.                      /* 6 = special for replication logging hook */
  1076.                /* 7 - table check constraint associated with column NOT NULL */
  1077.   robj#         number,                 /* object number of referenced table */
  1078.   rcon#         number,           /* constraint number of referenced columns */
  1079.   rrules        char(3),             /* future: use this columns for pendant */
  1080.   match         number,                /* referential constraint match type: */
  1081.                                                  /* null = FULL, 1 = PARTIAL */
  1082.         /* this column can also store information for other constraint types */
  1083.   refact        number,                               /* referential action: */
  1084.               /* null = RESTRICT, 1 = CASCADE, 2 = SET NULL, 3 = SET DEFAULT */
  1085.   enabled        number,          /* is constraint enabled? NULL if disabled */
  1086.   condlength    number,                 /* table check condition text length */
  1087.   condition     long,                          /* table check condition text */
  1088.   spare1        number)
  1089. cluster c_cobj#(obj#)
  1090. /
  1091. create table ccol$                                /* constraint column table */
  1092. ( con#          number not null,                        /* constraint number */
  1093.   obj#        number not null,               /* base object number */
  1094.   col#          number not null,                            /* column number */
  1095.   pos#          number,                 /* column position number as created */
  1096.   spare1        number)
  1097. cluster c_cobj#(obj#)
  1098. /
  1099. create index i_tab1 on tab$(clu#)
  1100. /
  1101. create unique index i_undo1 on undo$(us#)
  1102. /
  1103. create unique index i_obj1 on obj$(obj#)
  1104. /
  1105. create unique index i_obj2 on obj$(owner#, name, namespace,
  1106. remoteowner, linkname)
  1107. /
  1108. create unique index i_ind1 on ind$(obj#)
  1109. /
  1110. create index i_icol1 on icol$(obj#)
  1111. /
  1112. create unique index i_file1 on file$(file#)
  1113. /
  1114. create unique index i_user1 on user$(name)
  1115. /
  1116. create unique index i_col1 on col$(obj#, name)
  1117.   storage (initial 30k)
  1118. /
  1119. create unique index i_col2 on col$(obj#, col#)
  1120.   storage (initial 30k)
  1121. /
  1122. create unique index i_con1 on con$(owner#, name)
  1123. /
  1124. create unique index i_con2 on con$(con#)
  1125. /
  1126. create unique index i_cdef1 on cdef$(con#)
  1127. /
  1128. create index i_cdef2 on cdef$(obj#)
  1129. /
  1130. create index i_cdef3 on cdef$(robj#)
  1131. /
  1132. create unique index i_ccol1 on ccol$(con#, col#)
  1133. /
  1134. create table bootstrap$
  1135. ( line#         number not null,                       /* statement order id */
  1136.   obj#          number not null,                            /* object number */
  1137.   sql_text      long not null)                                  /* statement */
  1138.   storage (initial 50K)            /* to avoid space management during IOR I */
  1139. //
  1140. create table tsq$                                  /* tablespace quota table */
  1141. ( ts#           number not null,                        /* tablespace number */
  1142.   user#         number not null,                              /* user number */
  1143.   grantor#      number not null,                               /* grantor id */
  1144.   blocks        number not null,         /* number of blocks charged to user */
  1145.   maxblocks     number,     /* user's maximum number of blocks, NULL if none */
  1146.   priv1         number not null,            /* reserved for future privilege */
  1147.   priv2         number not null,            /* reserved for future privilege */
  1148.   priv3         number not null)            /* reserved for future privilege */
  1149. cluster c_user# (user#)
  1150. /
  1151. create table syn$                                           /* synonym table */
  1152. ( obj#          number not null,                /* object number */
  1153.   node        char("M_XDBI"),               /* node of object */
  1154.   owner     char("M_IDEN"),                          /* object owner */
  1155.   name        char("M_IDEN") not null)              /* object name */
  1156. /
  1157. create table view$                                             /* view table */
  1158. ( obj#          number not null,                /* object number */
  1159.   audit$    char("S_OPFL") not null,         /* auditing options */
  1160.   cols          number not null,            /* number of columns */
  1161.   textlength    number,                      /* length of view text */
  1162.   text          long)                        /* view text */
  1163. /
  1164. create table seq$
  1165. ( obj#            number not null,                            /* object number */
  1166.   increment$    number not null,            /* the sequence number increment */
  1167.   minvalue      number,                         /* minimum value of sequence */
  1168.   maxvalue      number,                         /* maximum value of sequence */
  1169.   cycle         number not null,                      /* 0 = FALSE, 1 = TRUE */
  1170.   order$        number not null,                      /* 0 = FALSE, 1 = TRUE */
  1171.   cache         number not null,                 /* how many to cache in sga */
  1172.   highwater     number not null,                     /* disk high water mark */
  1173.   audit$    char("S_OPFL") not null)             /* auditing options */
  1174. /
  1175. create table procedure$                          /* procedure table */
  1176. ( obj#          number not null,                /* object number */
  1177.   audit$    char("S_OPFL") not null,         /* auditing options */
  1178.   storagesize   number,                /* storage size of procedure */
  1179.   options       number)                               /* compile options */
  1180. /
  1181. create table argument$                     /* procedure argument description */
  1182. ( obj#           number not null,                           /* object number */ 
  1183.   procedure$     char(30),             /* procedure name (within a package) */ 
  1184.   overload#      number not null,
  1185.                 /* 0 = not overloaded, n = unique id of overloaded procedure */
  1186.   position       number not null,  /* argument position (0 for return value) */
  1187.   sequence#      number not null,
  1188.   level#         number not null,
  1189.   argument       char(30),          /* argument name (null for return value) */
  1190.   type           number not null,                           /* argument type */
  1191.   default#       number,   /* null = no default value, 1 = has default value */
  1192.   in_out         number,
  1193.   length         number,                                      /* data length */
  1194.   precision      number,                                /* numeric precision */
  1195.   scale          number,                                    /* numeric scale */
  1196.   radix          number,                                    /* numeric radix */
  1197.   deflength      number,             /* default value expression text length */
  1198.   default$       long)                      /* default value expression text */
  1199. /
  1200. create table source$                             /* source table */
  1201. ( obj#          number not null,                /* object number */
  1202.   line          number not null,                  /* line number */
  1203.   source        long)                                         /* source line */
  1204. /
  1205. create table idl_ub1$                            /* idl table for ub1 pieces */
  1206. ( obj#          number not null,                            /* object number */
  1207.   part          number not null,
  1208.          /* part: 0 = diana, 1 = portable pcode, 2 = machine-dependent pcode */
  1209.   version       number,                                    /* version number */
  1210.   piece#        number not null,                             /* piece number */
  1211.   length        number not null,                             /* piece length */
  1212.   piece         long raw not null)                              /* ub1 piece */
  1213. /
  1214. create table idl_char$                          /* idl table for char pieces */
  1215. ( obj#          number not null,                            /* object number */
  1216.   part          number not null,
  1217.          /* part: 0 = diana, 1 = portable pcode, 2 = machine-dependent pcode */
  1218.   version       number,                                    /* version number */
  1219.   piece#        number not null,                             /* piece number */
  1220.   length        number not null,                             /* piece length */
  1221.   piece         long not null)                                 /* char piece */
  1222. /
  1223. create table idl_ub2$                            /* idl table for ub2 pieces */
  1224. ( obj#          number not null,                            /* object number */
  1225.   part          number not null,
  1226.          /* part: 0 = diana, 1 = portable pcode, 2 = machine-dependent pcode */
  1227.   version       number,                                    /* version number */
  1228.   piece#        number not null,                             /* piece number */
  1229.   length        number not null,                             /* piece length */
  1230.   piece         long not null)                                  /* ub2 piece */
  1231. /
  1232. create table idl_sb4$                            /* idl table for sb4 pieces */
  1233. ( obj#          number not null,                            /* object number */
  1234.   part          number not null,
  1235.          /* part: 0 = diana, 1 = portable pcode, 2 = machine-dependent pcode */
  1236.   version       number,                                    /* version number */
  1237.   piece#        number not null,                             /* piece number */
  1238.   length        number not null,                             /* piece length */
  1239.   piece         long not null)                                  /* sb4 piece */
  1240. /
  1241. create table error$                                           /* error table */
  1242. ( obj#          number not null,                            /* object number */
  1243.   sequence      number default 0 not null,
  1244.                                   /* sequence number (for ordering purposes) */
  1245.   line          number not null,                              /* line number */
  1246.   position      number not null,                         /* position in line */
  1247.   textlength    number not null,                 /* length of the error text */
  1248.   text          long not null)                                 /* error text */
  1249. /
  1250. create table trigger$                            /* trigger table */
  1251. ( obj#        number not null,                /* object number */
  1252.   type          number not null,                            /* trigger type: */
  1253.         /*  0 = BEFORE TABLE, 1 = BEFORE ROW, 2 = AFTER TABLE, 3 = AFTER ROW */
  1254.   update$       number not null,                   /* fire on update */
  1255.   insert$       number not null,               /* fire on insert */
  1256.   delete$       number not null,               /* fire on delete */
  1257.   baseobject     number not null,                       /* triggering object */
  1258.   refoldname    char("M_IDEN"),                     /* old referencing name */
  1259.   refnewname    char("M_IDEN"),                     /* new referencing name */
  1260.   definition    char(255),                       /* trigger definition */
  1261.   whenclause    char(255),                            /* text of when clause */
  1262.   action        long,                                  /* action to fire */
  1263.   actionsize    number,                      /* size of action text */
  1264.   enabled       number)                /* 0 = DISABLED, 1 = ENABLED */
  1265. /
  1266. create table triggercol$
  1267. ( obj#        number not null,                /* object number */
  1268.   col#          number not null,                /* column number */
  1269.   type          number not null,                /* type of column reference: */
  1270.       /* 2 = OLD IN-ARG, 3 = NEW IN-ARG, 5 = NEW OUT-VAR, 7 = NEW IN/OUT-VAR */
  1271.   position      number)                      /* position in trigger */
  1272. /
  1273. #^ create_objauth()
  1274. create table sysauth$                          /* system authorization table */
  1275. ( grantee#     number not null,          /* grantee number (user# or role#) */
  1276.   privilege#     number not null,                      /* role or privilege # */
  1277.   sequence#    number not null,             /* unique grant sequence */
  1278.   option$    number)                     /* null = none, 1 = admin option */
  1279. /
  1280. create table objpriv$                       /* privileges granted to objects */
  1281. ( obj#          number not null,                            /* object number */
  1282.   privilege#     number not null)                         /* privilege number */
  1283. /
  1284. create table defrole$                                  /* default role table */
  1285. ( user#        number not null,                   /* user id */
  1286.   role#        number not null)                /* default role id */
  1287. /
  1288. create table profile$                                    /* resource profile */
  1289. ( profile#    number not null,   /* user$.resource$ and profname$.profile# */
  1290.   resource#    number not null,                          /* resource number */
  1291.   type        number not null,  /* 0 = kernel resource, else tool resource */
  1292.   limit        number not null)                           /* resource limit */
  1293. /
  1294. create table profname$                /* mapping of profile# to profile name */
  1295. ( profile#    number not null,
  1296.   name        char("M_IDEN") not null)
  1297. /
  1298. create table dependency$                                 /* dependency table */
  1299. ( d_obj#        number not null,                  /* dependent object number */
  1300.   d_timestamp   date not null,   /* dependent object specification timestamp */
  1301.   order#        number not null,                             /* order number */
  1302.   p_obj#        number not null,             /* parent object number */
  1303.   p_timestamp   date not null)      /* parent object specification timestamp */
  1304. /
  1305. create table access$                             /* access table */
  1306. ( d_obj#        number not null,              /* dependent object number */
  1307.   order#        number not null,                  /* dependency order number */
  1308.   columns       raw("M_BVCO"),                /* list of cols for this entry */
  1309.   types         number not null)                             /* access types */
  1310. /
  1311. create table lab$
  1312. ( lab#          number not null,           /* internal database label number */
  1313.   olab          raw(255),                   /* operating system label number */
  1314.   alias         char("M_IDEN"))                      /* alias for label name */
  1315. /
  1316. create table aud$                    /* audit trail table */
  1317. ( sessionid     number not null,
  1318.   entryid    number not null,
  1319.   statement    number not null,
  1320.   timestamp    date not null,
  1321.   userid    char("M_IDEN"),
  1322.   userhost    char("M_HOST"),
  1323.   terminal    char("M_TERM"),
  1324.   action    number not null,
  1325.   returncode    number not null,
  1326.   obj$creator    char("M_IDEN"),
  1327.   obj$name    char("M_XDBI"),
  1328.   auth$privileges char("S_PRFL"),
  1329.   auth$grantee    char("M_IDEN"),
  1330.   new$owner     char("M_IDEN"),
  1331.   new$name    char("M_XDBI"),
  1332.   ses$actions    char("S_ACFL"),
  1333.   ses$tid    number,
  1334.   logoff$lread    number,
  1335.   logoff$pread    number,
  1336.   logoff$lwrite number,
  1337.   logoff$dead    number,
  1338.   logoff$time    date,
  1339.   comment$text    long,
  1340.   spare1        char(255),
  1341.   spare2        number,
  1342.   obj$label     raw(255),                                   /* K_MLS changes */
  1343.   ses$label     raw(255),
  1344.   priv$used     number)
  1345. /
  1346. create table link$                             /* remote database link table */
  1347. ( owner#        number not null,                        /* owner user number */
  1348.   name          char("M_XDBI") not null,                  /* link name */
  1349.   ctime            date not null,                              /* creation time */
  1350.   host            char("M_HOST"),    /* optional driver string for connect */
  1351.   userid        char("M_IDEN"),             /* optional user to logon as */
  1352.   password      char("M_IDEN"))                    /* password for logon */
  1353. /
  1354. create table props$
  1355. ( name          char("M_IDEN") not null,                /* property name */
  1356.   value$        char(255),                        /* property value */
  1357.   comment$      char(255))               /* description of property */
  1358. /
  1359. create table com$                                           /* comment table */
  1360. ( obj#          number not null,                            /* object number */
  1361.   col#          number,               /* column number (NULL if for object) */
  1362.   comment$    long)           /* user-specified description */
  1363. /
  1364. create table resource_cost$
  1365. ( resource#    number not null,                         /* 2, 4, 6, 7, 8, 9 */
  1366.   cost        number not null)                                     /* >= 0 */
  1367. /
  1368. create unique index i_view1 on view$(obj#)
  1369. /
  1370. create unique index i_syn1 on syn$(obj#)
  1371. /
  1372. create unique index i_seq1 on seq$(obj#)
  1373. /
  1374. # defer creating this index until after we populate the table.
  1375. # the table objauth$ will not be unique after we copy it from v6;
  1376. # some pruning work will need to be done (later).
  1377. #
  1378. # create unique index i_objauth1 on 
  1379. #   objauth$(obj#, grantor#, grantee#, privilege#, col#)
  1380. # /
  1381. #^ create_i_objauth2()
  1382.  
  1383. create unique index i_sysauth1 on sysauth$(grantee#, privilege#)
  1384. /
  1385. create unique index i_defrole1 on defrole$(user#, role#)
  1386. /
  1387. create index i_aud1 on aud$(sessionid, ses$tid)
  1388. /
  1389. create index i_link1 on link$(owner#, name)
  1390. /
  1391. create unique index i_com1 on com$(obj#,col#)
  1392. /
  1393. create unique index i_procedure1 on procedure$(obj#)
  1394. /
  1395. create unique index i_argument1 on 
  1396.   argument$(obj#, procedure$, overload#, sequence#)
  1397. /
  1398. create unique index i_source1 on source$(obj#,line)
  1399. /
  1400. create unique index i_idl_ub11 on idl_ub1$(obj#, part, version, piece#)
  1401. /
  1402. create unique index i_idl_char1 on idl_char$(obj#, part, version, piece#)
  1403. /
  1404. create unique index i_idl_ub21 on idl_ub2$(obj#, part, version, piece#)
  1405. /
  1406. create unique index i_idl_sb41 on idl_sb4$(obj#, part, version, piece#)
  1407. /
  1408. create index i_error1 on error$(obj#, sequence)
  1409. /
  1410. create unique index i_dependency1 on dependency$(d_obj#, d_timestamp, order#)
  1411. /
  1412. create index i_access1 on access$(d_obj#)
  1413. /
  1414. create index i_dependency2 on dependency$(p_obj#, p_timestamp)
  1415. /
  1416. create index i_trigger1 on trigger$(baseobject)
  1417. /                                             
  1418. create unique index i_trigger2 on trigger$(obj#)
  1419. /
  1420. create index i_triggercol on triggercol$(obj#, col#, type, position)
  1421. /
  1422. create unique index i_profname on profname$(name)
  1423. /
  1424. create index i_profile on profile$(profile#)
  1425. /
  1426. create sequence label_translation   /* sequence for translation cache (lab$) */
  1427.   increment by 1
  1428.   start with 3
  1429.   minvalue 3
  1430.   nomaxvalue
  1431.   cache 20
  1432.   order
  1433.   nocycle
  1434. /
  1435. create sequence object_grant                 /* object grant sequence number */
  1436.   start with 1
  1437.   increment by 1
  1438.   minvalue 1
  1439.   nomaxvalue
  1440.   cache 20
  1441.   order
  1442.   nocycle
  1443. /
  1444. create sequence system_grant                 /* system grant sequence number */
  1445.   start with 1
  1446.   increment by 1
  1447.   minvalue 1
  1448.   nomaxvalue
  1449.   cache 20
  1450.   order
  1451.   nocycle
  1452. /
  1453. create sequence profnum$                   /* profile number sequence number */
  1454.   increment by 1
  1455.   start with 0                              /* profile# for DEFAULT always 0 */
  1456.   minvalue 0
  1457.   nocache                                           /* don't want to reuse 0 */
  1458. /
  1459. #create profile "DEFAULT" limit            /* default value, always present */
  1460. #  composite_limit        unlimited                   /* service units */
  1461. #  sessions_per_user        unlimited              /* logins per user id */
  1462. #  cpu_per_session        unlimited            /* cpu usage in minutes */
  1463. #  cpu_per_call            unlimited        /* max cpu minutes per call */
  1464. #  logical_reads_per_session    unlimited
  1465. #  logical_reads_per_call    unlimited
  1466. #  idle_time            unlimited
  1467. #  connect_time             unlimited
  1468. #  private_sga            unlimited      /* valid only with TP-monitor */
  1469. #/
  1470. create table incexp                      /* incremental export support table */
  1471. ( owner#        number not null,                                 /* owner id */
  1472.   name          char("M_IDEN") not null,                  /* object name */
  1473.   type            number(1) not null,                           /* object type */
  1474.   ctime            date,                      /* time of last cumulative export */
  1475.   itime            date not null,            /* time of last incremental export */
  1476.   expid         number(3) not null)                             /* export id */
  1477. /
  1478. create unique index i_incexp on incexp(owner#, name, type)
  1479. /
  1480. create table expact$
  1481. ( owner char(30) not null,                                 /* owner of table */
  1482.   name  char(30) not null,                                  /* name of table */
  1483.   func_schema char(30) not null,                 /* schema func is run under */
  1484.   func_package  char(30) not null,                           /* package name */
  1485.   func_proc  char(30) not null,                            /* procedure name */
  1486.   code  number not null,                            /* PRETABLE OR POSTTABLE */
  1487.   callorder number)
  1488. /
  1489. #create user sys identified by change_on_install
  1490. #/
  1491. #create role public
  1492. #/
  1493. #create role connect
  1494. #/
  1495. #grant create session,alter session,create synonym,create view,
  1496. # create database link to connect
  1497. #/
  1498. #create role resource
  1499. #/
  1500. #grant create table,create cluster,create sequence,create trigger,
  1501. # create procedure to resource
  1502. #/
  1503. #create role dba
  1504. #/
  1505. #grant all privileges to dba with admin option
  1506. #/
  1507. #create user system identified by manager
  1508. #/
  1509. #grant dba,unlimited tablespace to system with admin option
  1510. #/
  1511. #grant all on incexp to system
  1512. #/
  1513. create table incvid                    /* incremental valid identifier table */
  1514. ( expid         number(3) not null)               /* id of last valid export */
  1515. /
  1516. grant all on incvid to system
  1517. /
  1518. create table incfil                         /* incremental file export table */
  1519. ( expid         number(3) not null,                             /* export id */
  1520.   exptype       char(1) not null,                        /* export type: */
  1521.                                 /* f - full, i - incremental, c - cumulative */
  1522.   expfile       char(100) not null,                  /* export file name */
  1523.   expdate       date not null,                                /* export date */
  1524.   expuser       char("M_IDEN") not null)            /* user doing export */
  1525. /
  1526. grant all on incfil to system
  1527. /
  1528. create table "_default_auditing_options_"   /* default auditing option table */
  1529. ( a             char(1))                              /* auditing option */
  1530. /
  1531. #
  1532. # we don't need to create audses$ since it is carried over from v6
  1533. #
  1534. #create sequence audses$                               /* auditing session id */
  1535. #  start with 1
  1536. #  increment by 1
  1537. #  minvalue 1
  1538. #  maxvalue 2E9                                     /* maxvalue fits in a ub4 */
  1539. #  cycle
  1540. #  cache 20
  1541. #  noorder
  1542. #/
  1543. create table audit$                                 /* auditing option table */
  1544. ( user#        number not null,                   /* user identifier number */
  1545.   option#       number not null,                   /* auditing option number */
  1546.   success       number,                                 /* audit on success? */
  1547.   failure       number)                                 /* audit on failure? */
  1548.                /* null = no audit, 1 = audit by session, 2 = audit by access */
  1549. /
  1550. create unique index i_audit on audit$(user#, option#)
  1551.    /* this index is to ensure uniqueness and not performance */
  1552. /
  1553. create table pending_trans$        /* pending or "indoubt" transactions */
  1554. ( local_tran_id      char("M_LTID") not null, /* print form of kxid (local) */
  1555.   global_tran_fmt integer not null,               /* global tran format code */
  1556.   global_oracle_id  char("M_GTID"),                      /* Oracle k2gti */
  1557.   global_foreign_id raw("M_GTID"),                       /* non-Oracle k2gti */
  1558.   tran_comment      char("M_XCMT"),             /* commit/rollback comment */
  1559.   state          char(16) not null,       /* see k2.h: k2sta (tx state) */
  1560.   status          char(1) not null,                   /* Pending, Damage */
  1561.   heuristic_dflt  char(1),                  /* advice: Commit/Rollback/? */
  1562.   session_vector  raw(4) not null,              /* bit map of pending sess's */
  1563.   reco_vector      raw(4) not null,             /* map of sess's rdy for reco */
  1564.   fail_time      date not null,                            /* time inserted */
  1565.   heuristic_time  date,                        /* time of heuristic decision */
  1566.   reco_time      date not null,               /* last time tried (exp.b.o.) */
  1567.   top_db_user     char("M_IDEN"),        /* top level DB session created */
  1568.   top_os_user     char("M_UNML"),              /* top level OS user name */
  1569.   top_os_host      char("M_HOST"),         /* top level user OS host name */
  1570.   top_os_terminal char("M_TERM"),            /* top level OS terminal id */
  1571.   global_commit#  char(16) )              /* global system commit number */
  1572. /
  1573. create unique index i_pending_trans1 on pending_trans$(local_tran_id)
  1574.   /* this index is not for performance, but rather to ensure uniqueness */
  1575. /
  1576. create table pending_sessions$                  /* child of pending_trans$ */
  1577. ( local_tran_id   char("M_LTID") not null,                /* 1:n w/ parent */
  1578.   session_id      smallint not null,
  1579.   branch_id      raw("M_GBID") not null,                        /* of local */
  1580.   interface      char(1) not null,             /* C=commit/confirm, P=prep */
  1581.   parent_dbid      char("M_IDBI"),             /* null string->top level */
  1582.   parent_db      char("M_XDBI"),      /* global name of parent database */
  1583.   db_userid      integer not null)                 /* creator of DB session */
  1584. /
  1585. create table pending_sub_sessions$           /* child of pending_sessions$ */
  1586. ( local_tran_id   char("M_LTID") not null,    /* w/session_id,1:n w/parent */
  1587.   session_id      smallint not null,                             /* of local */
  1588.   sub_session_id  smallint not null, /* session,sub_session is remote branch */
  1589.   interface      char(1) not null,         /* C=hold commit, N=no hold */
  1590.   dbid          char("M_IDBI") not null,            /* of remote */
  1591.   link_owner      integer not null,              /* owner of dblink */
  1592.   dblink      char("M_XDBI") not null)
  1593. /
  1594. create cluster c_mlog# (master char("M_IDEN"),
  1595.                         mowner char("M_IDEN"))
  1596. /
  1597. create index i_mlog# on cluster c_mlog#
  1598. /
  1599. create table mlog$          /* list of local master tables used by snapshots */
  1600. ( mowner          char("M_IDEN") not null,            /* owner of master */
  1601.   master          char("M_IDEN") not null,             /* name of master */
  1602.   oldest          date,                                /* maximum age of log */
  1603.   oscn            number,                                   /* scn of oldest */
  1604.   youngest        date,                     /* most recent snaptime assigned */
  1605.   yscn            number,                                 /* scn of youngest */
  1606.   log             char("M_IDEN") not null,                /* name of log */
  1607.   trig            char("M_IDEN") not null)  /* trigger on master for log */
  1608. cluster c_mlog# (master, mowner)
  1609. /
  1610. create table slog$                     /* list of snapshots on local masters */
  1611. ( mowner          char("M_IDEN") not null,            /* owner of master */
  1612.   master          char("M_IDEN") not null,             /* name of master */
  1613.   snapshot        date,                               /* identifies snapshot */
  1614.   sscn            number,                                 /* scn of snapshot */
  1615.   snaptime        date               not null,        /* when last refreshed */
  1616.   tscn            number)                                 /* scn of snaptime */
  1617. cluster c_mlog# (master, mowner)
  1618. /
  1619. create index i_slog1 on slog$(snaptime)
  1620. /
  1621. create table snap$                                /* list of local snapshots */
  1622. ( sowner          char("M_IDEN") not null,              /* owner of snapshot */
  1623.   vname           char("M_IDEN") not null,          /* name of snapshot view */
  1624.   tname           char("M_IDEN") not null,         /* name of snapshot table */
  1625.   mview           char("M_IDEN") not null,     /* view snapshot is made from */
  1626.   mowner          char("M_IDEN"),                         /* owner of master */
  1627.   master          char("M_IDEN"),                          /* name of master */
  1628.   mlink           char("M_XDBI"),            /* database link to master site */
  1629.   can_use_log     char(1),                                         /* unused */
  1630.   snapshot        date,       /* used by the master to identify the snapshot */
  1631.   sscn            number,                                 /* scn of snapshot */
  1632.   snaptime        date,             /* when this snapshot was last refreshed */
  1633.   tscn            number,                                 /* scn of snaptime */
  1634.   error#          number,          /* last error caused by automatic refresh */
  1635.   auto_fast       char(1),            /* date function for automatic refresh */
  1636.   auto_fun        char("M_DATF"),         /* time for next automatic refresh */
  1637.   auto_date       date,             /* time for next automatic refresh force */
  1638.   refgroup        number,                    /* group for consistent refresh */
  1639.   ustrg           char("M_IDEN"),         /* trigger for updatable snapshots */
  1640.   uslog           char("M_IDEN"),             /* log for updatable snapshots */
  1641.   field1          number,                                  /* for future use */
  1642.   field2          char("M_IDEN"),                          /* for future use */
  1643.   flag            number,                     /* 0x01, can use master log    */
  1644.                                               /* 0x02, snapshot is updatable */
  1645.   query_txt       long)                /* query which this view instantiates */
  1646. /
  1647. create unique index i_snap1 on snap$(vname, sowner)
  1648. /
  1649. #  Job Queue
  1650. #
  1651. create sequence jobseq
  1652.   start with 1
  1653.   increment by 1
  1654.   minvalue 1
  1655.   maxvalue 999999999                        /* should be less than MAXSB4VAL */
  1656.   cache 20
  1657.   noorder
  1658.   cycle
  1659. /
  1660. create table job$
  1661. ( job             number not null,                  /* identifier of the job */
  1662.   lowner          char("M_IDEN") not null,             /* logged in user */
  1663.   powner          char("M_IDEN") not null,                   /* security */
  1664.   cowner          char("M_IDEN") not null,                    /* parsing */
  1665.   last_date       date,                      /* when this job last succeeded */
  1666.   this_date       date,    /* when the current execute started, usually null */
  1667.   next_date       date not null,             /* when to execute the job next */
  1668.   total           number default 0 not null, /* total time spent on this job */
  1669.   interval        char("M_DATF") not null,/* function for next next_date */
  1670.   failures        number,           /* number of failures since last success */
  1671.   flag            number default 0 not null,     /* 0x01, this job is broken */
  1672.   what            char(100),        /* PL/SQL text, what is the job */
  1673.   nlsenv          char(100),                      /* nls parameters */
  1674.   env             raw(32),                    /* other environment variables */
  1675.   cur_ses_label   char(20),      /* current session label for trusted oracle */
  1676.   clearance_hi    char(20),             /* clearance high for trusted oracle */
  1677.   clearance_lo    char(20),              /* clearance low for trusted oracle */
  1678.   charenv         char(100),                            /* not used */
  1679.   field1          number default 0)                              /* not used */
  1680. /
  1681. create unique index i_job_job on job$ (job)
  1682. /
  1683. create index i_job_next on job$ (next_date)
  1684. /
  1685. #
  1686. #  Refresh Groups
  1687. #
  1688. create sequence rgroupseq
  1689.   start with 1
  1690.   increment by 1
  1691.   minvalue 1
  1692.   maxvalue 999999999                        /* should be less than MAXSB4VAL */
  1693.   cache 20
  1694.   noorder
  1695.   cycle
  1696. /
  1697. create cluster c_rg#
  1698. ( refgroup        number)                            /* refresh group number */
  1699. /
  1700. create index i_rg# on cluster c_rg#
  1701. /
  1702. create table rgroup$
  1703. ( refgroup        number,                         /* number of refresh group */
  1704.   owner           char("M_IDEN") not null,     /* owner of refresh group */
  1705.   name            char("M_IDEN") not null,      /* name of refresh group */
  1706.   flag            number default 0,        /* 0x01, destroy group when empty */
  1707.                                                  /* 0x02, do not push queues */
  1708.                                                /* 0x04, refresh after errors */
  1709.   rollback_seg    char("M_IDEN"),                 /* rollback segment to use */
  1710.   field1          number default 0,
  1711.   job             number not null)  /* job in job$ for refreshing this group */
  1712. cluster c_rg# (refgroup)
  1713. /
  1714. create unique index i_rgroup on rgroup$ (owner, name)
  1715. /
  1716. create unique index i_rgref on rgroup$ (refgroup)
  1717. /
  1718. create index i_rgjob on rgroup$ (job)
  1719. /
  1720. create table rgchild$
  1721. ( owner           char("M_IDEN") not null,             /* owner of child */
  1722.   name            char("M_IDEN") not null,              /* name of child */
  1723.   type            char("M_IDEN") default 'SNAPSHOT',   /* type of object */
  1724.   field1          number default 0,
  1725.   refgroup        number)                   /* refresh group the child is in */
  1726. cluster c_rg# (refgroup)
  1727. /
  1728. create unique index i_rgchild on rgchild$ (owner, name, type)
  1729. /
  1730. #
  1731. #  Drop User Cascade
  1732. #
  1733. create table duc$
  1734. ( owner           char("M_IDEN") not null,            /* procedure owner */
  1735.   pack            char("M_IDEN") not null,          /* procedure package */
  1736.   proc            char("M_IDEN") not null,             /* procedure name */
  1737.   field1          number default 0,
  1738.   operation       number not null,                    /* 1=drop user cascade */
  1739.   seq             number not null,            /* for ordering the procedures */
  1740.   com             char(80))       /* comment on what this routine is for */
  1741. /
  1742. create unique index i_duc on duc$ (owner,pack,proc,operation)
  1743. /
  1744. #
  1745. #  Histograms
  1746. create cluster hist$
  1747. ( obj#            number,                                   /* object number */
  1748.   col#            number)                                   /* column number */
  1749.   pctfree 5 size 200
  1750. /
  1751. create index i_hist$ on cluster hist$
  1752. /
  1753. create table histogram$                                   /* histogram table */
  1754. ( obj#            number not null,                          /* object number */
  1755.   col#            number not null,                          /* column number */
  1756.   bucket          number not null,                          /* bucket number */
  1757.   endpoint        number not null,                  /* endpoint hashed value */
  1758.   endpointr       raw(32))                             /* endpoint raw value */
  1759. cluster hist$(obj#, col#)
  1760. /
  1761. create table dual (dummy char(1))    /* pl/sql's standard pckg requires dual */
  1762. /
  1763. insert into dual values('X')
  1764. /
  1765. create public synonym dual for dual
  1766. /
  1767. grant select on dual to public with grant option
  1768. /
  1769. #
  1770. #  FAMILY "PRIVILEGE MAP"
  1771. #  Tables for mapping privilege numbers to privilege names.
  1772. #
  1773. #  SYSTEM_PRIVILEGE_MAP maps a system privilege  number
  1774. #  to the name.
  1775. #
  1776. create table SYSTEM_PRIVILEGE_MAP (
  1777.         PRIVILEGE       number not null,
  1778.         NAME            char(40) not null)
  1779. /
  1780. comment on table SYSTEM_PRIVILEGE_MAP is
  1781. 'Description table for privilege type codes.  Maps privilege  type numbers to type names'
  1782. /
  1783. comment on column SYSTEM_PRIVILEGE_MAP.PRIVILEGE is
  1784. 'Numeric privilege type code'
  1785. /
  1786. comment on column SYSTEM_PRIVILEGE_MAP.NAME is
  1787. 'Name of the type of privilege'
  1788. /
  1789. insert into SYSTEM_PRIVILEGE_MAP values (-3, 'ALTER SYSTEM');
  1790. insert into SYSTEM_PRIVILEGE_MAP values (-4, 'AUDIT SYSTEM');
  1791. insert into SYSTEM_PRIVILEGE_MAP values (-5, 'CREATE SESSION');
  1792. insert into SYSTEM_PRIVILEGE_MAP values (-6, 'ALTER SESSION');
  1793. insert into SYSTEM_PRIVILEGE_MAP values (-7, 'RESTRICTED SESSION');
  1794. insert into SYSTEM_PRIVILEGE_MAP values (-10, 'CREATE TABLESPACE');
  1795. insert into SYSTEM_PRIVILEGE_MAP values (-11, 'ALTER TABLESPACE');
  1796. insert into SYSTEM_PRIVILEGE_MAP values (-12, 'MANAGE TABLESPACE');
  1797. insert into SYSTEM_PRIVILEGE_MAP values (-13, 'DROP TABLESPACE');
  1798. insert into SYSTEM_PRIVILEGE_MAP values (-15, 'UNLIMITED TABLESPACE');
  1799. insert into SYSTEM_PRIVILEGE_MAP values (-20, 'CREATE USER');
  1800. insert into SYSTEM_PRIVILEGE_MAP values (-21, 'BECOME USER');
  1801. insert into SYSTEM_PRIVILEGE_MAP values (-22, 'ALTER USER');
  1802. insert into SYSTEM_PRIVILEGE_MAP values (-23, 'DROP USER');
  1803. insert into SYSTEM_PRIVILEGE_MAP values (-30, 'CREATE ROLLBACK SEGMENT');
  1804. insert into SYSTEM_PRIVILEGE_MAP values (-31, 'ALTER ROLLBACK SEGMENT');
  1805. insert into SYSTEM_PRIVILEGE_MAP values (-32, 'DROP ROLLBACK SEGMENT');
  1806. insert into SYSTEM_PRIVILEGE_MAP values (-40, 'CREATE TABLE');
  1807. insert into SYSTEM_PRIVILEGE_MAP values (-41, 'CREATE ANY TABLE');
  1808. insert into SYSTEM_PRIVILEGE_MAP values (-42, 'ALTER ANY TABLE');
  1809. insert into SYSTEM_PRIVILEGE_MAP values (-43, 'BACKUP ANY TABLE');
  1810. insert into SYSTEM_PRIVILEGE_MAP values (-44, 'DROP ANY TABLE');
  1811. insert into SYSTEM_PRIVILEGE_MAP values (-45, 'LOCK ANY TABLE');
  1812. insert into SYSTEM_PRIVILEGE_MAP values (-46, 'COMMENT ANY TABLE');
  1813. insert into SYSTEM_PRIVILEGE_MAP values (-47, 'SELECT ANY TABLE');
  1814. insert into SYSTEM_PRIVILEGE_MAP values (-48, 'INSERT ANY TABLE');
  1815. insert into SYSTEM_PRIVILEGE_MAP values (-49, 'UPDATE ANY TABLE');
  1816. insert into SYSTEM_PRIVILEGE_MAP values (-50, 'DELETE ANY TABLE');
  1817. insert into SYSTEM_PRIVILEGE_MAP values (-60, 'CREATE CLUSTER');
  1818. insert into SYSTEM_PRIVILEGE_MAP values (-61, 'CREATE ANY CLUSTER');
  1819. insert into SYSTEM_PRIVILEGE_MAP values (-62, 'ALTER ANY CLUSTER');
  1820. insert into SYSTEM_PRIVILEGE_MAP values (-63, 'DROP ANY CLUSTER');
  1821. insert into SYSTEM_PRIVILEGE_MAP values (-71, 'CREATE ANY INDEX');
  1822. insert into SYSTEM_PRIVILEGE_MAP values (-72, 'ALTER ANY INDEX');
  1823. insert into SYSTEM_PRIVILEGE_MAP values (-73, 'DROP ANY INDEX');
  1824. insert into SYSTEM_PRIVILEGE_MAP values (-80, 'CREATE SYNONYM');
  1825. insert into SYSTEM_PRIVILEGE_MAP values (-81, 'CREATE ANY SYNONYM');
  1826. insert into SYSTEM_PRIVILEGE_MAP values (-82, 'DROP ANY SYNONYM');
  1827. insert into SYSTEM_PRIVILEGE_MAP values (-83, 'SYSDBA');
  1828. insert into SYSTEM_PRIVILEGE_MAP values (-84, 'SYSOPER');
  1829. insert into SYSTEM_PRIVILEGE_MAP values (-85, 'CREATE PUBLIC SYNONYM');
  1830. insert into SYSTEM_PRIVILEGE_MAP values (-86, 'DROP PUBLIC SYNONYM');
  1831. insert into SYSTEM_PRIVILEGE_MAP values (-90, 'CREATE VIEW');
  1832. insert into SYSTEM_PRIVILEGE_MAP values (-91, 'CREATE ANY VIEW');
  1833. insert into SYSTEM_PRIVILEGE_MAP values (-92, 'DROP ANY VIEW');
  1834. insert into SYSTEM_PRIVILEGE_MAP values (-105, 'CREATE SEQUENCE');
  1835. insert into SYSTEM_PRIVILEGE_MAP values (-106, 'CREATE ANY SEQUENCE');
  1836. insert into SYSTEM_PRIVILEGE_MAP values (-107, 'ALTER ANY SEQUENCE');
  1837. insert into SYSTEM_PRIVILEGE_MAP values (-108, 'DROP ANY SEQUENCE');
  1838. insert into SYSTEM_PRIVILEGE_MAP values (-109, 'SELECT ANY SEQUENCE');
  1839. insert into SYSTEM_PRIVILEGE_MAP values (-115, 'CREATE DATABASE LINK');
  1840. insert into SYSTEM_PRIVILEGE_MAP values (-120, 'CREATE PUBLIC DATABASE LINK');
  1841. insert into SYSTEM_PRIVILEGE_MAP values (-121, 'DROP PUBLIC DATABASE LINK');
  1842. insert into SYSTEM_PRIVILEGE_MAP values (-125, 'CREATE ROLE');
  1843. insert into SYSTEM_PRIVILEGE_MAP values (-126, 'DROP ANY ROLE');
  1844. insert into SYSTEM_PRIVILEGE_MAP values (-127, 'GRANT ANY ROLE');
  1845. insert into SYSTEM_PRIVILEGE_MAP values (-128, 'ALTER ANY ROLE');
  1846. insert into SYSTEM_PRIVILEGE_MAP values (-130, 'AUDIT ANY');
  1847. insert into SYSTEM_PRIVILEGE_MAP values (-135, 'ALTER DATABASE');
  1848. insert into SYSTEM_PRIVILEGE_MAP values (-138, 'FORCE TRANSACTION');
  1849. insert into SYSTEM_PRIVILEGE_MAP values (-139, 'FORCE ANY TRANSACTION');
  1850. insert into SYSTEM_PRIVILEGE_MAP values (-140, 'CREATE PROCEDURE');
  1851. insert into SYSTEM_PRIVILEGE_MAP values (-141, 'CREATE ANY PROCEDURE');
  1852. insert into SYSTEM_PRIVILEGE_MAP values (-142, 'ALTER ANY PROCEDURE');
  1853. insert into SYSTEM_PRIVILEGE_MAP values (-143, 'DROP ANY PROCEDURE');
  1854. insert into SYSTEM_PRIVILEGE_MAP values (-144, 'EXECUTE ANY PROCEDURE');
  1855. insert into SYSTEM_PRIVILEGE_MAP values (-151, 'CREATE TRIGGER');
  1856. insert into SYSTEM_PRIVILEGE_MAP values (-152, 'CREATE ANY TRIGGER');
  1857. insert into SYSTEM_PRIVILEGE_MAP values (-153, 'ALTER ANY TRIGGER');
  1858. insert into SYSTEM_PRIVILEGE_MAP values (-154, 'DROP ANY TRIGGER');
  1859. insert into SYSTEM_PRIVILEGE_MAP values (-160, 'CREATE PROFILE');
  1860. insert into SYSTEM_PRIVILEGE_MAP values (-161, 'ALTER PROFILE');
  1861. insert into SYSTEM_PRIVILEGE_MAP values (-162, 'DROP PROFILE');
  1862. insert into SYSTEM_PRIVILEGE_MAP values (-163, 'ALTER RESOURCE COST');
  1863. insert into SYSTEM_PRIVILEGE_MAP values (-165, 'ANALYZE ANY');
  1864. insert into SYSTEM_PRIVILEGE_MAP values (-167, 'GRANT ANY PRIVILEGE');
  1865. insert into SYSTEM_PRIVILEGE_MAP values (-172, 'CREATE SNAPSHOT');
  1866. insert into SYSTEM_PRIVILEGE_MAP values (-173, 'CREATE ANY SNAPSHOT');
  1867. insert into SYSTEM_PRIVILEGE_MAP values (-174, 'ALTER ANY SNAPSHOT');
  1868. insert into SYSTEM_PRIVILEGE_MAP values (-175, 'DROP ANY SNAPSHOT');
  1869. insert into SYSTEM_PRIVILEGE_MAP values (-197, 'WRITEDOWN');
  1870. insert into SYSTEM_PRIVILEGE_MAP values (-198, 'READUP');
  1871. insert into SYSTEM_PRIVILEGE_MAP values (-199, 'WRITEUP');
  1872. create unique index I_SYSTEM_PRIVILEGE_MAP
  1873.         on SYSTEM_PRIVILEGE_MAP (PRIVILEGE, NAME)
  1874. /
  1875. drop public synonym SYSTEM_PRIVILEGE_MAP
  1876. /
  1877. create public synonym SYSTEM_PRIVILEGE_MAP for SYSTEM_PRIVILEGE_MAP
  1878. /
  1879. grant select on SYSTEM_PRIVILEGE_MAP to public with grant option
  1880. /
  1881. #
  1882. #  TABLE_PRIVILEGE_MAP maps a table privilege (auditing option) number
  1883. #  to the name.
  1884. #
  1885. create table TABLE_PRIVILEGE_MAP (
  1886.         PRIVILEGE       number not null,
  1887.         NAME            char(40) not null)
  1888. /
  1889. comment on table TABLE_PRIVILEGE_MAP is
  1890. 'Description table for privilege (auditing option) type codes.  Maps privilege (auditing option) type numbers to type names'
  1891. /
  1892. comment on column TABLE_PRIVILEGE_MAP.PRIVILEGE is
  1893. 'Numeric privilege (auditing option) type code'
  1894. /
  1895. comment on column TABLE_PRIVILEGE_MAP.NAME is
  1896. 'Name of the type of privilege (auditing option)'
  1897. /
  1898. insert into TABLE_PRIVILEGE_MAP values (0, 'ALTER');
  1899. insert into TABLE_PRIVILEGE_MAP values (1, 'AUDIT');
  1900. insert into TABLE_PRIVILEGE_MAP values (2, 'COMMENT');
  1901. insert into TABLE_PRIVILEGE_MAP values (3, 'DELETE');
  1902. insert into TABLE_PRIVILEGE_MAP values (4, 'GRANT');
  1903. insert into TABLE_PRIVILEGE_MAP values (5, 'INDEX');
  1904. insert into TABLE_PRIVILEGE_MAP values (6, 'INSERT');
  1905. insert into TABLE_PRIVILEGE_MAP values (7, 'LOCK');
  1906. insert into TABLE_PRIVILEGE_MAP values (8, 'RENAME');
  1907. insert into TABLE_PRIVILEGE_MAP values (9, 'SELECT');
  1908. insert into TABLE_PRIVILEGE_MAP values (10, 'UPDATE');
  1909. insert into TABLE_PRIVILEGE_MAP values (11, 'REFERENCES');
  1910. insert into TABLE_PRIVILEGE_MAP values (12, 'EXECUTE');
  1911. create unique index I_TABLE_PRIVILEGE_MAP
  1912.         on TABLE_PRIVILEGE_MAP (PRIVILEGE, NAME)
  1913. /
  1914. drop public synonym TABLE_PRIVILEGE_MAP
  1915. /
  1916. create public synonym TABLE_PRIVILEGE_MAP for TABLE_PRIVILEGE_MAP
  1917. /
  1918. grant select on TABLE_PRIVILEGE_MAP to public with grant option
  1919. /
  1920. #
  1921. #  FAMILY "OPTION MAP"
  1922. #    Tables for mapping auditing option numbers to auditing 
  1923. #  the name.
  1924. #
  1925. #  STMT_AUDIT_OPTION_MAP maps a auditing option number to the name.
  1926. #
  1927. create table STMT_AUDIT_OPTION_MAP (
  1928.     OPTION#            number not null,
  1929.     NAME            char(40) not null)
  1930. /
  1931. comment on table STMT_AUDIT_OPTION_MAP is
  1932. 'Description table for auditing option type codes.  Maps auditing option type numbers to type names'
  1933. /
  1934. comment on column STMT_AUDIT_OPTION_MAP.OPTION# is
  1935. 'Numeric auditing option type code'
  1936. /
  1937. comment on column STMT_AUDIT_OPTION_MAP.NAME is
  1938. 'Name of the type of auditing option'
  1939. /
  1940. insert into STMT_AUDIT_OPTION_MAP values (  3, 'ALTER SYSTEM');
  1941. insert into STMT_AUDIT_OPTION_MAP values (  4, 'SYSTEM AUDIT');
  1942. insert into STMT_AUDIT_OPTION_MAP values (  5, 'CREATE SESSION');
  1943. insert into STMT_AUDIT_OPTION_MAP values (  6, 'ALTER SESSION');
  1944. insert into STMT_AUDIT_OPTION_MAP values (  7, 'RESTRICTED SESSION');
  1945. insert into STMT_AUDIT_OPTION_MAP values (  8, 'TABLE');
  1946. insert into STMT_AUDIT_OPTION_MAP values (  9, 'CLUSTER');
  1947. insert into STMT_AUDIT_OPTION_MAP values ( 10, 'CREATE TABLESPACE');
  1948. insert into STMT_AUDIT_OPTION_MAP values ( 11, 'ALTER TABLESPACE');
  1949. insert into STMT_AUDIT_OPTION_MAP values ( 12, 'MANAGE TABLESPACE');
  1950. insert into STMT_AUDIT_OPTION_MAP values ( 13, 'DROP TABLESPACE');
  1951. insert into STMT_AUDIT_OPTION_MAP values ( 14, 'TABLESPACE');
  1952. insert into STMT_AUDIT_OPTION_MAP values ( 15, 'UNLIMITED TABLESPACE');
  1953. insert into STMT_AUDIT_OPTION_MAP values ( 16, 'USER');
  1954. insert into STMT_AUDIT_OPTION_MAP values ( 17, 'ROLLBACK SEGMENT');
  1955. insert into STMT_AUDIT_OPTION_MAP values ( 19, 'INDEX');
  1956. insert into STMT_AUDIT_OPTION_MAP values ( 20, 'CREATE USER');
  1957. insert into STMT_AUDIT_OPTION_MAP values ( 21, 'BECOME USER');
  1958. insert into STMT_AUDIT_OPTION_MAP values ( 22, 'ALTER USER');
  1959. insert into STMT_AUDIT_OPTION_MAP values ( 23, 'DROP USER');
  1960. insert into STMT_AUDIT_OPTION_MAP values ( 24, 'SYNONYM');
  1961. insert into STMT_AUDIT_OPTION_MAP values ( 25, 'PUBLIC SYNONYM');
  1962. insert into STMT_AUDIT_OPTION_MAP values ( 26, 'VIEW');
  1963. insert into STMT_AUDIT_OPTION_MAP values ( 27, 'SEQUENCE');
  1964. insert into STMT_AUDIT_OPTION_MAP values ( 28, 'DATABASE LINK');
  1965. insert into STMT_AUDIT_OPTION_MAP values ( 29, 'PUBLIC DATABASE LINK');
  1966. insert into STMT_AUDIT_OPTION_MAP values ( 30, 'CREATE ROLLBACK SEGMENT');
  1967. insert into STMT_AUDIT_OPTION_MAP values ( 31, 'ALTER ROLLBACK SEGMENT');
  1968. insert into STMT_AUDIT_OPTION_MAP values ( 32, 'DROP ROLLBACK SEGMENT');
  1969. insert into STMT_AUDIT_OPTION_MAP values ( 33, 'ROLE');
  1970. insert into STMT_AUDIT_OPTION_MAP values ( 35, 'PROCEDURE');
  1971. insert into STMT_AUDIT_OPTION_MAP values ( 36, 'TRIGGER');
  1972. insert into STMT_AUDIT_OPTION_MAP values ( 37, 'PROFILE');
  1973. insert into STMT_AUDIT_OPTION_MAP values ( 40, 'CREATE TABLE');
  1974. insert into STMT_AUDIT_OPTION_MAP values ( 41, 'CREATE ANY TABLE');
  1975. insert into STMT_AUDIT_OPTION_MAP values ( 42, 'ALTER ANY TABLE');
  1976. insert into STMT_AUDIT_OPTION_MAP values ( 43, 'BACKUP ANY TABLE');
  1977. insert into STMT_AUDIT_OPTION_MAP values ( 44, 'DROP ANY TABLE');
  1978. insert into STMT_AUDIT_OPTION_MAP values ( 45, 'LOCK ANY TABLE');
  1979. insert into STMT_AUDIT_OPTION_MAP values ( 46, 'COMMENT ANY TABLE');
  1980. insert into STMT_AUDIT_OPTION_MAP values ( 47, 'SELECT ANY TABLE');
  1981. insert into STMT_AUDIT_OPTION_MAP values ( 48, 'INSERT ANY TABLE');
  1982. insert into STMT_AUDIT_OPTION_MAP values ( 49, 'UPDATE ANY TABLE');
  1983. insert into STMT_AUDIT_OPTION_MAP values ( 50, 'DELETE ANY TABLE');
  1984. insert into STMT_AUDIT_OPTION_MAP values ( 60, 'CREATE CLUSTER');
  1985. insert into STMT_AUDIT_OPTION_MAP values ( 61, 'CREATE ANY CLUSTER');
  1986. insert into STMT_AUDIT_OPTION_MAP values ( 62, 'ALTER ANY CLUSTER');
  1987. insert into STMT_AUDIT_OPTION_MAP values ( 63, 'DROP ANY CLUSTER');
  1988. insert into STMT_AUDIT_OPTION_MAP values ( 71, 'CREATE ANY INDEX');
  1989. insert into STMT_AUDIT_OPTION_MAP values ( 72, 'ALTER ANY INDEX');
  1990. insert into STMT_AUDIT_OPTION_MAP values ( 73, 'DROP ANY INDEX');
  1991. insert into STMT_AUDIT_OPTION_MAP values ( 80, 'CREATE SYNONYM');
  1992. insert into STMT_AUDIT_OPTION_MAP values ( 81, 'CREATE ANY SYNONYM');
  1993. insert into STMT_AUDIT_OPTION_MAP values ( 82, 'DROP ANY SYNONYM');
  1994. insert into STMT_AUDIT_OPTION_MAP values ( 83, 'SYSDBA');
  1995. insert into STMT_AUDIT_OPTION_MAP values ( 84, 'SYSOPER');
  1996. insert into STMT_AUDIT_OPTION_MAP values ( 85, 'CREATE PUBLIC SYNONYM');
  1997. insert into STMT_AUDIT_OPTION_MAP values ( 86, 'DROP PUBLIC SYNONYM');
  1998. insert into STMT_AUDIT_OPTION_MAP values ( 90, 'CREATE VIEW');
  1999. insert into STMT_AUDIT_OPTION_MAP values ( 91, 'CREATE ANY VIEW');
  2000. insert into STMT_AUDIT_OPTION_MAP values ( 92, 'DROP ANY VIEW');
  2001. insert into STMT_AUDIT_OPTION_MAP values (105, 'CREATE SEQUENCE');
  2002. insert into STMT_AUDIT_OPTION_MAP values (106, 'CREATE ANY SEQUENCE');
  2003. insert into STMT_AUDIT_OPTION_MAP values (107, 'ALTER ANY SEQUENCE');
  2004. insert into STMT_AUDIT_OPTION_MAP values (108, 'DROP ANY SEQUENCE');
  2005. insert into STMT_AUDIT_OPTION_MAP values (109, 'SELECT ANY SEQUENCE');
  2006. insert into STMT_AUDIT_OPTION_MAP values (111, 'GRANT SEQUENCE');
  2007. insert into STMT_AUDIT_OPTION_MAP values (115, 'CREATE DATABASE LINK');
  2008. insert into STMT_AUDIT_OPTION_MAP values (120, 'CREATE PUBLIC DATABASE LINK');
  2009. insert into STMT_AUDIT_OPTION_MAP values (121, 'DROP PUBLIC DATABASE LINK');
  2010. insert into STMT_AUDIT_OPTION_MAP values (125, 'CREATE ROLE');
  2011. insert into STMT_AUDIT_OPTION_MAP values (126, 'DROP ANY ROLE');
  2012. insert into STMT_AUDIT_OPTION_MAP values (127, 'GRANT ANY ROLE');
  2013. insert into STMT_AUDIT_OPTION_MAP values (128, 'ALTER ANY ROLE');
  2014. insert into STMT_AUDIT_OPTION_MAP values (130, 'AUDIT ANY');
  2015. insert into STMT_AUDIT_OPTION_MAP values (131, 'SYSTEM GRANT');
  2016. insert into STMT_AUDIT_OPTION_MAP values (135, 'ALTER DATABASE');
  2017. insert into STMT_AUDIT_OPTION_MAP values (138, 'FORCE TRANSACTION');
  2018. insert into STMT_AUDIT_OPTION_MAP values (139, 'FORCE ANY TRANSACTION');
  2019. insert into STMT_AUDIT_OPTION_MAP values (140, 'CREATE PROCEDURE');
  2020. insert into STMT_AUDIT_OPTION_MAP values (141, 'CREATE ANY PROCEDURE');
  2021. insert into STMT_AUDIT_OPTION_MAP values (142, 'ALTER ANY PROCEDURE');
  2022. insert into STMT_AUDIT_OPTION_MAP values (143, 'DROP ANY PROCEDURE');
  2023. insert into STMT_AUDIT_OPTION_MAP values (144, 'EXECUTE ANY PROCEDURE');
  2024. insert into STMT_AUDIT_OPTION_MAP values (146, 'EXECUTE PROCEDURE');
  2025. insert into STMT_AUDIT_OPTION_MAP values (147, 'GRANT PROCEDURE');
  2026. insert into STMT_AUDIT_OPTION_MAP values (151, 'CREATE TRIGGER');
  2027. insert into STMT_AUDIT_OPTION_MAP values (152, 'CREATE ANY TRIGGER');
  2028. insert into STMT_AUDIT_OPTION_MAP values (153, 'ALTER ANY TRIGGER');
  2029. insert into STMT_AUDIT_OPTION_MAP values (154, 'DROP ANY TRIGGER');
  2030. insert into STMT_AUDIT_OPTION_MAP values (160, 'CREATE PROFILE');
  2031. insert into STMT_AUDIT_OPTION_MAP values (161, 'ALTER PROFILE');
  2032. insert into STMT_AUDIT_OPTION_MAP values (162, 'DROP PROFILE');
  2033. insert into STMT_AUDIT_OPTION_MAP values (163, 'ALTER RESOURCE COST');
  2034. insert into STMT_AUDIT_OPTION_MAP values (165, 'ANALYZE ANY');
  2035. insert into STMT_AUDIT_OPTION_MAP values (167, 'GRANT ANY PRIVILEGE');
  2036. insert into STMT_AUDIT_OPTION_MAP values (172, 'CREATE SNAPSHOT');
  2037. insert into STMT_AUDIT_OPTION_MAP values (173, 'CREATE ANY SNAPSHOT');
  2038. insert into STMT_AUDIT_OPTION_MAP values (174, 'ALTER ANY SNAPSHOT');
  2039. insert into STMT_AUDIT_OPTION_MAP values (175, 'DROP ANY SNAPSHOT');
  2040. insert into STMT_AUDIT_OPTION_MAP values (197, 'WRITEDOWN');
  2041. insert into STMT_AUDIT_OPTION_MAP values (198, 'READUP');
  2042. insert into STMT_AUDIT_OPTION_MAP values (199, 'WRITEUP');
  2043. insert into STMT_AUDIT_OPTION_MAP values ( 77, 'NOT EXISTS');
  2044. insert into STMT_AUDIT_OPTION_MAP values ( 87, 'EXISTS');
  2045. insert into STMT_AUDIT_OPTION_MAP values ( 54, 'ALTER TABLE');
  2046. insert into STMT_AUDIT_OPTION_MAP values ( 57, 'LOCK TABLE');
  2047. insert into STMT_AUDIT_OPTION_MAP values ( 58, 'COMMENT TABLE');
  2048. insert into STMT_AUDIT_OPTION_MAP values ( 65, 'SELECT TABLE');
  2049. insert into STMT_AUDIT_OPTION_MAP values ( 66, 'INSERT TABLE');
  2050. insert into STMT_AUDIT_OPTION_MAP values ( 67, 'UPDATE TABLE');
  2051. insert into STMT_AUDIT_OPTION_MAP values ( 68, 'DELETE TABLE');
  2052. insert into STMT_AUDIT_OPTION_MAP values ( 69, 'GRANT TABLE');
  2053. insert into STMT_AUDIT_OPTION_MAP values (103, 'ALTER SEQUENCE');
  2054. insert into STMT_AUDIT_OPTION_MAP values (104, 'SELECT SEQUENCE');
  2055. create unique index I_STMT_AUDIT_OPTION_MAP
  2056.         on STMT_AUDIT_OPTION_MAP (OPTION#, NAME)
  2057. /
  2058. drop public synonym STMT_AUDIT_OPTION_MAP
  2059. /
  2060. create public synonym  STMT_AUDIT_OPTION_MAP for STMT_AUDIT_OPTION_MAP
  2061. /
  2062. grant select on STMT_AUDIT_OPTION_MAP to public
  2063. /
  2064. #
  2065. # FAMILY "RESOURCE PROFILES"
  2066. #
  2067. create table RESOURCE_MAP (
  2068.     RESOURCE#    number not null,
  2069.     NAME        char(32) not null)
  2070. /
  2071. comment on table RESOURCE_MAP is
  2072. 'Description table for resources.  Maps resource name to number'
  2073. /
  2074. comment on column RESOURCE_MAP.RESOURCE# is
  2075. 'Numeric resource code'
  2076. /
  2077. comment on column RESOURCE_MAP.NAME is
  2078. 'Name of resource'
  2079. /
  2080. insert into resource_map values ( 0, 'COMPOSITE_LIMIT' );
  2081. insert into resource_map values ( 1, 'SESSIONS_PER_USER' );
  2082. insert into resource_map values ( 2, 'CPU_PER_SESSION' );
  2083. insert into resource_map values ( 3, 'CPU_PER_CALL' );
  2084. insert into resource_map values ( 4, 'LOGICAL_READS_PER_SESSION' );
  2085. insert into resource_map values ( 5, 'LOGICAL_READS_PER_CALL' );
  2086. insert into resource_map values ( 6, 'IDLE_TIME' );
  2087. insert into resource_map values ( 7, 'CONNECT_TIME' );
  2088. insert into resource_map values ( 8, 'PRIVATE_SGA' )
  2089. /
  2090. create table uet$                                       /* used extent table */
  2091. ( segfile#      number not null,               /* segment header file number */
  2092.   segblock#     number not null,              /* segment header block number */
  2093.   ext#          number not null,         /* extent number within the segment */
  2094.   ts#           number not null,        /* tablespace containing this extent */
  2095.   file#         number not null,              /* file containing this extent */
  2096.   block#        number not null,              /* starting dba of this extent */
  2097.   length        number not null)          /* length in blocks of this extent */
  2098. cluster c_file#_block#(segfile#, segblock#)
  2099. /
  2100. create table seg$                                           /* segment table */
  2101. ( file#         number not null,               /* segment header file number */
  2102.   block#        number not null,              /* segment header block number */
  2103.   type          number not null,                /* segment type (see KTS.H): */
  2104.    /* 1 = UNDO, 2 = SAVE UNDO, 3 = TEMPORARY, 4 = CACHE, 5 = DATA, 6 = INDEX */
  2105.   ts#           number not null,       /* tablespace containing this segment */
  2106.   blocks        number not null,       /* blocks allocated to segment so far */
  2107.   extents       number not null,      /* extents allocated to segment so far */
  2108.   iniexts       number not null,                      /* initial extent size */
  2109.   minexts       number not null,                /* minimum number of extents */
  2110.   maxexts       number not null,                /* maximum number of extents */
  2111.   extsize       number not null,                 /* initial next extent size */
  2112.   extpct        number not null,                    /* percent size increase */
  2113.   user#         number not null,               /* user who owns this segment */
  2114.   lists            number,                        /* freelists for this segment */
  2115.   groups        number)                  /* freelist groups for this segment */
  2116. cluster c_file#_block#(file#, block#)
  2117. /
  2118. # the following is required by the parallel query option:
  2119. create sequence ora_tq_base$
  2120.   start with 1
  2121.   increment by 1
  2122.   nominvalue
  2123.   nomaxvalue
  2124.   nocache
  2125.   noorder
  2126.   nocycle
  2127. /
  2128.  
  2129. #
  2130. # m_convert
  2131. #
  2132. insert into tab$ select obj#, ts#, file#, block#, clu#, tab#, cols, clucols,
  2133.    pctfree$, pctused$, initrans, maxtrans, modified, 
  2134.    substr (audit$, 1, 22) || '----',
  2135.    NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL from sys.tab$;
  2136. insert into clu$ select obj#, ts#, file#, block#, cols, pctfree$, pctused$,
  2137.    initrans, maxtrans, size$, hashfunc, 0, 0, 0, 0, 0, 0, 0, 0, 0 
  2138.    from sys.clu$;
  2139. insert into undo$ select us#, name, user#, file#, block#, scnbas, scnwrp,
  2140.    xactsqn, undosqn, NULL, status$ from sys.undo$;
  2141. insert into ts$ select ts#, name, owner#, online$, undofile#, undoblock#, 
  2142.    blocksize, inc#, 0, 0, dflminext, dflmaxext, dflinit, dflincr, dflextpct
  2143.    from sys.ts$;
  2144. #^ set_clean_offline()
  2145. insert into file$ select * from sys.file$;
  2146. insert into col$ select obj#, col#, segcol#, segcollength, offset, name, 
  2147.    type#, length, fixedstorage, precision, scale, null$, 0, 
  2148.    lowval, hival, deflength, NULL, 0, 0 from sys.col$;
  2149. #^ copy_long (sys, col$, default$, migrate, col$, default$, obj#, col#)
  2150. insert into user$ select user#, name, 1, password, datats#, tempts#, ctime,
  2151.    ptime, 0, audit$, 1, 0, 0 from sys.user$;
  2152. insert into con$ select owner#, name, con#, NULL from sys.con$;
  2153. insert into cdef$ select con#, obj#, cols, type, robj#, rcon#, rrules, NULL, 
  2154.    NULL, NULL, condlength, NULL, NULL from sys.cdef$;
  2155. #^ copy_long (sys, cdef$, condition, migrate, cdef$, condition, con#)
  2156.  
  2157. #
  2158. # by default all constraints in cdef$ are disabled (enabled = null).
  2159. # however, columns in v6 that are not null should be enabled (103146 & 103233)
  2160. #
  2161. update cdef$ set cdef$.enabled = 1 where cdef$.con# in
  2162.    (select col$.null$ from col$ where col$.null$ > 0);
  2163.  
  2164. insert into ccol$ select con#, obj#, col#, pos#, NULL from sys.ccol$;
  2165.  
  2166. insert into tsq$ select * from sys.tsq$;
  2167. insert into syn$ select * from sys.syn$;
  2168.  
  2169. # move synonym for dual to sys
  2170. update syn$ set owner = 'SYS' where owner = 'MIGRATE';
  2171.  
  2172. # edit any synonym that uses a dblink by adding the default domain if they
  2173. # do not already have a domain
  2174. update syn$ set node = upper(node) || '.WORLD'
  2175.  where node is not null
  2176.    and node not like '%.%';
  2177.  
  2178. insert into view$ select obj#,
  2179.    '--' || substr (audit$, 3, 8) || '--' || substr (audit$, 13, 10) || '----',
  2180.    cols, textlength, NULL from sys.view$;
  2181. #^ copy_long (sys, view$, text, migrate, view$, text, obj#)
  2182. insert into seq$ select obj#, increment$, minvalue, maxvalue, cycle,
  2183.    order$, cache, highwater, 
  2184.    substr (audit$, 1, 4) || '----' || substr (audit$, 9, 2) ||
  2185.      '--------' || substr (audit$, 19, 2) || '------'
  2186.    from sys.seq$;
  2187. insert into aud$ select sessionid, entryid, statement, timestamp, userid,
  2188.    userhost, terminal, action, returncode, obj$creator, obj$name, 
  2189.    auth$privileges, auth$grantee, NULL, new$name, ses$actions, ses$tid, 
  2190.    logoff$lread, logoff$pread, logoff$lwrite, logoff$dead, logoff$time, 
  2191.    comment$text, NULL, 0, NULL, NULL, NULL from sys.aud$;
  2192. insert into link$ select owner#, upper (name) || '.WORLD',
  2193.                          ctime, host, userid, password from sys.link$;
  2194. insert into props$ select * from sys.props$;
  2195. #insert into props$ values('NLS_LANGUAGE','AMERICAN','Language');
  2196. #insert into props$ values('NLS_TERRITORY','AMERICA','Territory');
  2197. #insert into props$ values('NLS_CURRENCY','$','Local currency');
  2198. #insert into props$ values('NLS_ISO_CURRENCY','AMERICA','ISO currency');
  2199. #insert into props$ values('NLS_NUMERIC_CHARACTERS','.,','Numeric characters');
  2200. #insert into props$ values('NLS_DATE_FORMAT','DD-MON-YY','Date format');
  2201. #insert into props$ values('NLS_DATE_LANGUAGE','AMERICAN','Date language');
  2202. #insert into props$ values('NLS_CHARACTERSET','US7ASCII','Character set');
  2203. #insert into props$ values('NLS_SORT','BINARY','Linguistic definition');
  2204. insert into props$ values('GLOBAL_DB_NAME','CHANGE_ON_INSTALL.WORLD','Global database name');
  2205. insert into com$ select * from sys.com$;
  2206. insert into incexp select * from sys.incexp;
  2207. insert into incvid select * from sys.incvid;
  2208. insert into incfil select * from sys.incfil;
  2209.  
  2210. insert into "_default_auditing_options_" 
  2211.    select * from sys."_default_auditing_options_";
  2212.  
  2213. #
  2214. #  the following is from conv6to7.bsq
  2215. #
  2216.  
  2217. # Convert colauth$ and tabauth$ into objauth$
  2218. # tmpidx is use to sort and order the rows of tabauth$ and colauth$ by grant
  2219. # sequence number (the sequence# column).  The grants must be inserted into
  2220. # objauth$ in the V6 sequence# order because the V7 sequence# column is
  2221. # generated via object_grant.nextval.  The V7 sequence# column cannot simply be
  2222. # copied from the V6 sequence# column because a single tabauth$ row may
  2223. # become several objauth$ rows.  An order by in the where clause of the
  2224. # sub-select would achieve the same thing as tmpidx, but order-by's are not
  2225. # allowed in the sub-select of an insert statement.
  2226. #^ connect (maint, internal)
  2227. create index tmpidx on tabauth$(sequence#);
  2228. #^ connect (migrate, migrate)
  2229. insert into objauth$(obj#,grantor#,grantee#,privilege#,sequence#,option$) 
  2230.   select obj#,grantor#,grantee#,0,object_grant.nextval,decode(alter$,3,1,null)
  2231.   from sys.tabauth$ x where 
  2232.      ((x.alter$=2 and not exists(select 1 from sys.tabauth$ y where
  2233.                          y.alter$=3 and
  2234.                                  x.obj#=y.obj# and x.grantor# = y.grantor# and
  2235.                                  x.grantee#=y.grantee#))
  2236.        or x.alter$=3) and x.sequence#>0
  2237. /
  2238. insert into objauth$(obj#,grantor#,grantee#,privilege#,sequence#,option$) 
  2239.   select obj#,grantor#,grantee#,3,object_grant.nextval,decode(delete$,3,1,null)
  2240.   from sys.tabauth$ x where
  2241.      ((x.delete$=2 and not exists(select 1 from sys.tabauth$ y where
  2242.                          y.delete$=3 and
  2243.                                  x.obj#=y.obj# and x.grantor# = y.grantor# and
  2244.                                  x.grantee#=y.grantee#))
  2245.        or x.delete$=3) and x.sequence#>0
  2246. /
  2247. insert into objauth$(obj#,grantor#,grantee#,privilege#,sequence#,option$) 
  2248.   select obj#,grantor#,grantee#,5,object_grant.nextval,decode(index$,3,1,null)
  2249.   from sys.tabauth$ x where
  2250.      ((x.index$=2 and not exists(select 1 from sys.tabauth$ y where
  2251.                          y.index$=3 and
  2252.                                  x.obj#=y.obj# and x.grantor# = y.grantor# and
  2253.                                  x.grantee#=y.grantee#))
  2254.        or x.index$=3) and x.sequence#>0
  2255. /
  2256. insert into objauth$(obj#,grantor#,grantee#,privilege#,sequence#,option$) 
  2257.   select obj#,grantor#,grantee#,6,object_grant.nextval,decode(insert$,3,1,null)
  2258.   from sys.tabauth$ x where
  2259.      ((x.insert$=2 and not exists(select 1 from sys.tabauth$ y where
  2260.                          y.insert$=3 and
  2261.                                  x.obj#=y.obj# and x.grantor# = y.grantor# and
  2262.                                  x.grantee#=y.grantee#))
  2263.        or x.insert$=3) and x.sequence#>0
  2264. /
  2265. insert into objauth$(obj#,grantor#,grantee#,privilege#,sequence#,option$) 
  2266.   select obj#,grantor#,grantee#,9,object_grant.nextval,decode(select$,3,1,null)
  2267.   from sys.tabauth$ x where
  2268.      ((x.select$=2 and not exists(select 1 from sys.tabauth$ y where
  2269.                          y.select$=3 and
  2270.                                  x.obj#=y.obj# and x.grantor# = y.grantor# and
  2271.                                  x.grantee#=y.grantee#))
  2272.        or x.select$=3) and x.sequence#>0
  2273. /
  2274. insert into objauth$(obj#,grantor#,grantee#,privilege#,sequence#,option$) 
  2275.   select obj#,grantor#,grantee#,10,object_grant.nextval,decode(update$,3,1,null)
  2276.   from sys.tabauth$ x where
  2277.      ((x.update$=2 and not exists(select 1 from sys.tabauth$ y where
  2278.                          y.update$=3 and
  2279.                                  x.obj#=y.obj# and x.grantor# = y.grantor# and
  2280.                                  x.grantee#=y.grantee#))
  2281.        or x.update$=3) and x.sequence#>0
  2282. /
  2283. insert into objauth$(obj#,grantor#,grantee#,privilege#,sequence#,option$) 
  2284.   select obj#,grantor#,grantee#,11,object_grant.nextval,decode(references$,1,null)
  2285.   from sys.tabauth$ x where
  2286.      ((x.references$=2 and not exists(select 1 from sys.tabauth$ y where
  2287.                          y.references$=3 and
  2288.                                  x.obj#=y.obj# and x.grantor# = y.grantor# and
  2289.                                  x.grantee#=y.grantee#))
  2290.        or x.references$=3) and x.sequence#>0
  2291. /
  2292. #^ connect (maint, internal)
  2293. drop index tmpidx;
  2294. create index tmpidx on colauth$(sequence#);
  2295. #^ connect (migrate, migrate)
  2296.  
  2297. insert into objauth$(obj#,grantor#,grantee#,privilege#,sequence#,option$,col#) 
  2298.   select col$.obj#,grantor#,grantee#,10,object_grant.nextval,
  2299.   decode(update$,3,1,null),col# 
  2300.   from sys.colauth$ x,sys.col$ 
  2301.   where col$.name=x.name and col$.obj# = x.obj#
  2302.     and ((x.update$=2 and not exists(select 1 from sys.colauth$ y where
  2303.                                      (y.update$=3 and
  2304.                                           x.obj#=y.obj# and
  2305.                           x.grantor# = y.grantor# and
  2306.                                           x.grantee#=y.grantee#)
  2307.                      or
  2308.                      (y.update$=2 and
  2309.                       x.obj#=y.obj# and
  2310.                           x.grantor# = y.grantor# and
  2311.                                           x.grantee#=y.grantee# and
  2312.                       y.rowid > x.rowid)))
  2313.         or (x.update$=3 and not exists (select 1 from sys.colauth$ y where
  2314.                         y.update$=3 and
  2315.                         x.obj#=y.obj# and
  2316.                             x.grantor# = y.grantor# and
  2317.                                             x.grantee#=y.grantee# and
  2318.                         y.rowid > x.rowid)))
  2319.     and x.sequence#>0
  2320. /
  2321. insert into objauth$(obj#,grantor#,grantee#,privilege#,sequence#,option$,col#) 
  2322.   select col$.obj#,grantor#,grantee#,10,object_grant.nextval,
  2323.   decode(references$,3,1,null),col# 
  2324.   from sys.colauth$ x,sys.col$ 
  2325.   where col$.name=x.name and col$.obj# = x.obj#
  2326.     and ((x.references$=2 and not exists(select 1 from sys.colauth$ y where
  2327.                                      (y.references$=3 and
  2328.                                           x.obj#=y.obj# and
  2329.                           x.grantor# = y.grantor# and
  2330.                                           x.grantee#=y.grantee#)
  2331.                      or
  2332.                      (y.references$=2 and
  2333.                       x.obj#=y.obj# and
  2334.                           x.grantor# = y.grantor# and
  2335.                                           x.grantee#=y.grantee# and
  2336.                       y.rowid > x.rowid)))
  2337.         or (x.references$=3 and not exists (select 1 from sys.colauth$ y where
  2338.                         y.references$=3 and
  2339.                         x.obj#=y.obj# and
  2340.                             x.grantor# = y.grantor# and
  2341.                                             x.grantee#=y.grantee# and
  2342.                         y.rowid > x.rowid)))
  2343.     and x.sequence#>0
  2344. /
  2345. #^ connect (maint, internal)
  2346. drop index tmpidx;
  2347. #^ connect (migrate, migrate)
  2348.  
  2349. # Delete any un-needed grants
  2350. delete from objauth$ a where not exists
  2351.   (select 1 from sys.obj$ o where o.obj# = a.obj#);
  2352.  
  2353. # we need to create the index here after we insert into objauth above.
  2354. # the inserts will create duplicate entries in objauth which we have just 
  2355. #   purged.  now we can create the unique index i_objauth1 
  2356. #
  2357. #^ create_i_objauth1()
  2358.  
  2359. #
  2360. # Now populate IND$ and ICOL$
  2361. #
  2362. insert into ind$ select obj#, ts#, file#, block#, bo#, cols, pctfree$, 
  2363.    initrans, maxtrans, compress$, unique$, 
  2364.    0, 0, 0, 0, 0, 0, 0, 0 from sys.ind$;
  2365. insert into icol$ select * from sys.icol$;
  2366.  
  2367. #
  2368. # Now populate obj$.  After this statement, no new objects can be
  2369. # created in this script.
  2370. #
  2371. insert into obj$ select obj#, owner#, name,
  2372.    decode (type, 1, 4, 3, 5, 1),
  2373.    type, ctime, mtime, mtime, 1, NULL, NULL from sys.obj$;
  2374.  
  2375. # Create Connect, Resource and Dba roles 
  2376. insert into user$ (user#, name, type, datats#, tempts#, ctime, resource$,
  2377.     defrole) 
  2378.     select user#, 'CONNECT', 0, 0, 0, sysdate, 0, 1 from sys.user$ 
  2379.     where name = '_NEXT_USER';
  2380. insert into user$ (user#, name, type, datats#, tempts#, ctime, resource$,
  2381.     defrole)
  2382.     select user# + 1, 'RESOURCE', 0, 0, 0, sysdate, 0, 1 from sys.user$
  2383.     where name = '_NEXT_USER';
  2384. insert into user$ (user#, name, type, datats#, tempts#, ctime, resource$,
  2385.     defrole)
  2386.     select user# + 2, 'DBA', 0, 0, 0, sysdate, 0, 1 from sys.user$
  2387.     where name = '_NEXT_USER';
  2388. update user$ set user#=user#+3 where name='_NEXT_USER';
  2389.  
  2390. # Change Public to a role
  2391. update user$ set type=0,defrole=1 where name='PUBLIC'
  2392. /
  2393. # Convert user$ privileges into sysauth$ entries
  2394. insert into sysauth$(grantee#, privilege#, sequence#) 
  2395.   select user#, -1, system_grant.nextval from sys.user$ where connect$=1
  2396.   and user#!=1
  2397. /
  2398. update sysauth$ set privilege#=(select user# from user$ where name='CONNECT')
  2399.   where privilege#=-1
  2400. /
  2401. insert into sysauth$(grantee#, privilege#, sequence#) 
  2402.   select user#, -1, system_grant.nextval from sys.user$ where resource$=1
  2403.   and user#!=1
  2404. /
  2405. update sysauth$ set privilege#=(select user# from user$ where name='RESOURCE')
  2406.   where privilege#=-1
  2407. /
  2408. insert into sysauth$(grantee#, privilege#, sequence#) 
  2409.   select user#, -1, system_grant.nextval from sys.user$ where dba$=1
  2410.   and user#!=1
  2411. /
  2412. update sysauth$ set privilege#=(select user# from user$ where name='DBA')
  2413.   where privilege#=-1
  2414. /
  2415. # Grant create sequence priv to anyone who had resource() on a tablespace 
  2416. insert into sysauth$(grantee#,privilege#,sequence#) 
  2417.   select tsq$.user#,-105,-1
  2418.   from sys.tsq$,sys.user$
  2419.   where tsq$.user#=user$.user# and maxblocks is null
  2420.     and user$.resource$!=0
  2421. /
  2422. update sysauth$ set sequence# = system_grant.nextval where sequence# = -1
  2423. /
  2424. # Grant each user who had v6 RESOURCE privilege the "unlimited tablespace"
  2425. # privilege.
  2426. #
  2427. insert into sysauth$(grantee#, privilege#, sequence#)
  2428.    select user#, -15, system_grant.nextval from sys.user$ 
  2429.    where resource$ = 1 and dba$ != 1;
  2430.  
  2431. # Grant each user who had v6 DBA privilege the "unlimited tablespace" 
  2432. # privilege with the admin option.
  2433. #
  2434. insert into sysauth$(grantee#, privilege#, sequence#, option$)
  2435.    select user#, -15, system_grant.nextval, 1 from sys.user$ where dba$ = 1;
  2436.  
  2437. # Perform grants to Connect, Resource and Dba roles
  2438. insert into sysauth$(grantee#, privilege#, sequence#) 
  2439.   values (-1, -5, system_grant.nextval)
  2440. /
  2441. insert into sysauth$(grantee#, privilege#, sequence#) 
  2442.   values (-1, -6, system_grant.nextval)
  2443. /
  2444. insert into sysauth$(grantee#, privilege#, sequence#) 
  2445.   values (-1, -80, system_grant.nextval)
  2446. /
  2447. insert into sysauth$(grantee#, privilege#, sequence#) 
  2448.   values (-1, -90, system_grant.nextval)
  2449. /
  2450. insert into sysauth$(grantee#, privilege#, sequence#) 
  2451.   values (-1, -115, system_grant.nextval)
  2452. /
  2453. insert into sysauth$(grantee#, privilege#, sequence#) 
  2454.   values (-1, -40, system_grant.nextval)
  2455. /
  2456. insert into sysauth$(grantee#, privilege#, sequence#) 
  2457.   values (-1, -60, system_grant.nextval)
  2458. /
  2459. insert into sysauth$(grantee#, privilege#, sequence#) 
  2460.   values (-1, -105, system_grant.nextval)
  2461. /
  2462. update sysauth$ set grantee#=(select user# from user$ where name='CONNECT')
  2463.   where grantee#=-1
  2464. /
  2465. insert into sysauth$(grantee#, privilege#, sequence#) 
  2466.   values (-1, -40, system_grant.nextval)
  2467. /
  2468. insert into sysauth$(grantee#, privilege#, sequence#) 
  2469.   values (-1, -60, system_grant.nextval)
  2470. /
  2471. insert into sysauth$(grantee#, privilege#, sequence#) 
  2472.   values (-1, -105, system_grant.nextval)
  2473. /
  2474. insert into sysauth$(grantee#, privilege#, sequence#) 
  2475.   values (-1, -140, system_grant.nextval)
  2476. /
  2477. insert into sysauth$(grantee#, privilege#, sequence#) 
  2478.   values (-1, -151, system_grant.nextval)
  2479. /
  2480. update sysauth$ set grantee#=(select user# from user$ where name='RESOURCE')
  2481.   where grantee#=-1
  2482. /
  2483. insert into sysauth$(grantee#, privilege#, sequence#, option$)
  2484.   values (-1, -3  ,system_grant.nextval, 1)
  2485. /
  2486. insert into sysauth$(grantee#, privilege#, sequence#, option$)
  2487.   values (-1, -4  ,system_grant.nextval, 1)
  2488. /
  2489. insert into sysauth$(grantee#, privilege#, sequence#, option$)
  2490.   values (-1, -5  ,system_grant.nextval, 1)
  2491. /
  2492. insert into sysauth$(grantee#, privilege#, sequence#, option$)
  2493.   values (-1, -6  ,system_grant.nextval, 1)
  2494. /
  2495. insert into sysauth$(grantee#, privilege#, sequence#, option$)
  2496.   values (-1, -7  ,system_grant.nextval, 1)
  2497. /
  2498. insert into sysauth$(grantee#, privilege#, sequence#, option$)
  2499.   values (-1, -10 ,system_grant.nextval, 1)
  2500. /
  2501. insert into sysauth$(grantee#, privilege#, sequence#, option$)
  2502.   values (-1, -11 ,system_grant.nextval, 1)
  2503. /
  2504. insert into sysauth$(grantee#, privilege#, sequence#, option$)
  2505.   values (-1, -12 ,system_grant.nextval, 1)
  2506. /
  2507. insert into sysauth$(grantee#, privilege#, sequence#, option$)
  2508.   values (-1, -13 ,system_grant.nextval, 1)
  2509. /
  2510. insert into sysauth$(grantee#, privilege#, sequence#, option$)
  2511.   values (-1, -20 ,system_grant.nextval, 1)
  2512. /
  2513. insert into sysauth$(grantee#, privilege#, sequence#, option$)
  2514.   values (-1, -21 ,system_grant.nextval, 1)
  2515. /
  2516. insert into sysauth$(grantee#, privilege#, sequence#, option$)
  2517.   values (-1, -22 ,system_grant.nextval, 1)
  2518. /
  2519. insert into sysauth$(grantee#, privilege#, sequence#, option$)
  2520.   values (-1, -23 ,system_grant.nextval, 1)
  2521. /
  2522. insert into sysauth$(grantee#, privilege#, sequence#, option$)
  2523.   values (-1, -30 ,system_grant.nextval, 1)
  2524. /
  2525. insert into sysauth$(grantee#, privilege#, sequence#, option$)
  2526.   values (-1, -31 ,system_grant.nextval, 1)
  2527. /
  2528. insert into sysauth$(grantee#, privilege#, sequence#, option$)
  2529.   values (-1, -32 ,system_grant.nextval, 1)
  2530. /
  2531. insert into sysauth$(grantee#, privilege#, sequence#, option$)
  2532.   values (-1, -40 ,system_grant.nextval, 1)
  2533. /
  2534. insert into sysauth$(grantee#, privilege#, sequence#, option$)
  2535.   values (-1, -41 ,system_grant.nextval, 1)
  2536. /
  2537. insert into sysauth$(grantee#, privilege#, sequence#, option$)
  2538.   values (-1, -42 ,system_grant.nextval, 1)
  2539. /
  2540. insert into sysauth$(grantee#, privilege#, sequence#, option$)
  2541.   values (-1, -43 ,system_grant.nextval, 1)
  2542. /
  2543. insert into sysauth$(grantee#, privilege#, sequence#, option$)
  2544.   values (-1, -44 ,system_grant.nextval, 1)
  2545. /
  2546. insert into sysauth$(grantee#, privilege#, sequence#, option$)
  2547.   values (-1, -45 ,system_grant.nextval, 1)
  2548. /
  2549. insert into sysauth$(grantee#, privilege#, sequence#, option$)
  2550.   values (-1, -46 ,system_grant.nextval, 1)
  2551. /
  2552. insert into sysauth$(grantee#, privilege#, sequence#, option$)
  2553.   values (-1, -47 ,system_grant.nextval, 1)
  2554. /
  2555. insert into sysauth$(grantee#, privilege#, sequence#, option$)
  2556.   values (-1, -48 ,system_grant.nextval, 1)
  2557. /
  2558. insert into sysauth$(grantee#, privilege#, sequence#, option$)
  2559.   values (-1, -49 ,system_grant.nextval, 1)
  2560. /
  2561. insert into sysauth$(grantee#, privilege#, sequence#, option$)
  2562.   values (-1, -50 ,system_grant.nextval, 1)
  2563. /
  2564. insert into sysauth$(grantee#, privilege#, sequence#, option$)
  2565.   values (-1, -60 ,system_grant.nextval, 1)
  2566. /
  2567. insert into sysauth$(grantee#, privilege#, sequence#, option$)
  2568.   values (-1, -61 ,system_grant.nextval, 1)
  2569. /
  2570. insert into sysauth$(grantee#, privilege#, sequence#, option$)
  2571.   values (-1, -62 ,system_grant.nextval, 1)
  2572. /
  2573. insert into sysauth$(grantee#, privilege#, sequence#, option$)
  2574.   values (-1, -63 ,system_grant.nextval, 1)
  2575. /
  2576. insert into sysauth$(grantee#, privilege#, sequence#, option$)
  2577.   values (-1, -71 ,system_grant.nextval, 1)
  2578. /
  2579. insert into sysauth$(grantee#, privilege#, sequence#, option$)
  2580.   values (-1, -72 ,system_grant.nextval, 1)
  2581. /
  2582. insert into sysauth$(grantee#, privilege#, sequence#, option$)
  2583.   values (-1, -73 ,system_grant.nextval, 1)
  2584. /
  2585. insert into sysauth$(grantee#, privilege#, sequence#, option$)
  2586.   values (-1, -80 ,system_grant.nextval, 1)
  2587. /
  2588. insert into sysauth$(grantee#, privilege#, sequence#, option$)
  2589.   values (-1, -81 ,system_grant.nextval, 1)
  2590. /
  2591. insert into sysauth$(grantee#, privilege#, sequence#, option$)
  2592.   values (-1, -82 ,system_grant.nextval, 1)
  2593. /
  2594. insert into sysauth$(grantee#, privilege#, sequence#, option$)
  2595.   values (-1, -85 ,system_grant.nextval, 1)
  2596. /
  2597. insert into sysauth$(grantee#, privilege#, sequence#, option$)
  2598.   values (-1, -86 ,system_grant.nextval, 1)
  2599. /
  2600. insert into sysauth$(grantee#, privilege#, sequence#, option$)
  2601.   values (-1, -90 ,system_grant.nextval, 1)
  2602. /
  2603. insert into sysauth$(grantee#, privilege#, sequence#, option$)
  2604.   values (-1, -91 ,system_grant.nextval, 1)
  2605. /
  2606. insert into sysauth$(grantee#, privilege#, sequence#, option$)
  2607.   values (-1, -92 ,system_grant.nextval, 1)
  2608. /
  2609. insert into sysauth$(grantee#, privilege#, sequence#, option$)
  2610.   values (-1, -105 ,system_grant.nextval, 1)
  2611. /
  2612. insert into sysauth$(grantee#, privilege#, sequence#, option$)
  2613.   values (-1, -106,system_grant.nextval, 1)
  2614. /
  2615. insert into sysauth$(grantee#, privilege#, sequence#, option$)
  2616.   values (-1, -107,system_grant.nextval, 1)
  2617. /
  2618. insert into sysauth$(grantee#, privilege#, sequence#, option$)
  2619.   values (-1, -108,system_grant.nextval, 1)
  2620. /
  2621. insert into sysauth$(grantee#, privilege#, sequence#, option$)
  2622.   values (-1, -109,system_grant.nextval, 1)
  2623. /
  2624. insert into sysauth$(grantee#, privilege#, sequence#, option$)
  2625.   values (-1, -115,system_grant.nextval, 1)
  2626. /
  2627. insert into sysauth$(grantee#, privilege#, sequence#, option$)
  2628.   values (-1, -120,system_grant.nextval, 1)
  2629. /
  2630. insert into sysauth$(grantee#, privilege#, sequence#, option$)
  2631.   values (-1, -121,system_grant.nextval, 1)
  2632. /
  2633. insert into sysauth$(grantee#, privilege#, sequence#, option$)
  2634.   values (-1, -125,system_grant.nextval, 1)
  2635. /
  2636. insert into sysauth$(grantee#, privilege#, sequence#, option$)
  2637.   values (-1, -126,system_grant.nextval, 1)
  2638. /
  2639. insert into sysauth$(grantee#, privilege#, sequence#, option$)
  2640.   values (-1, -127,system_grant.nextval, 1)
  2641. /
  2642. insert into sysauth$(grantee#, privilege#, sequence#, option$)
  2643.   values (-1, -128,system_grant.nextval, 1)
  2644. /
  2645. insert into sysauth$(grantee#, privilege#, sequence#, option$)
  2646.   values (-1, -130,system_grant.nextval, 1)
  2647. /
  2648. insert into sysauth$(grantee#, privilege#, sequence#, option$)
  2649.   values (-1, -131,system_grant.nextval, 1)
  2650. /
  2651. insert into sysauth$(grantee#, privilege#, sequence#, option$)
  2652.   values (-1, -135,system_grant.nextval, 1)
  2653. /
  2654. insert into sysauth$(grantee#, privilege#, sequence#, option$)
  2655.   values (-1, -138,system_grant.nextval, 1)
  2656. /
  2657. insert into sysauth$(grantee#, privilege#, sequence#, option$)
  2658.   values (-1, -139,system_grant.nextval, 1)
  2659. /
  2660. insert into sysauth$(grantee#, privilege#, sequence#, option$)
  2661.   values (-1, -140,system_grant.nextval, 1)
  2662. /
  2663. insert into sysauth$(grantee#, privilege#, sequence#, option$)
  2664.   values (-1, -141,system_grant.nextval, 1)
  2665. /
  2666. insert into sysauth$(grantee#, privilege#, sequence#, option$)
  2667.   values (-1, -142,system_grant.nextval, 1)
  2668. /
  2669. insert into sysauth$(grantee#, privilege#, sequence#, option$)
  2670.   values (-1, -143,system_grant.nextval, 1)
  2671. /
  2672. insert into sysauth$(grantee#, privilege#, sequence#, option$)
  2673.   values (-1, -144,system_grant.nextval, 1)
  2674. /
  2675. insert into sysauth$(grantee#, privilege#, sequence#, option$)
  2676.   values (-1, -151,system_grant.nextval, 1)
  2677. /
  2678. insert into sysauth$(grantee#, privilege#, sequence#, option$)
  2679.   values (-1, -152,system_grant.nextval, 1)
  2680. /
  2681. insert into sysauth$(grantee#, privilege#, sequence#, option$)
  2682.   values (-1, -153,system_grant.nextval, 1)
  2683. /
  2684. insert into sysauth$(grantee#, privilege#, sequence#, option$)
  2685.   values (-1, -154,system_grant.nextval, 1)
  2686. /
  2687. insert into sysauth$(grantee#, privilege#, sequence#, option$)
  2688.   values (-1, -160,system_grant.nextval, 1)
  2689. /
  2690. insert into sysauth$(grantee#, privilege#, sequence#, option$)
  2691.   values (-1, -161,system_grant.nextval, 1)
  2692. /
  2693. insert into sysauth$(grantee#, privilege#, sequence#, option$)
  2694.   values (-1, -162,system_grant.nextval, 1)
  2695. /
  2696. insert into sysauth$(grantee#, privilege#, sequence#, option$)
  2697.   values (-1, -163,system_grant.nextval, 1)
  2698. /
  2699. insert into sysauth$(grantee#, privilege#, sequence#, option$)
  2700.   values (-1, -165,system_grant.nextval, 1)
  2701. /
  2702. insert into sysauth$(grantee#, privilege#, sequence#, option$)
  2703.   values (-1, -167,system_grant.nextval, 1)
  2704. /
  2705. insert into sysauth$(grantee#, privilege#, sequence#, option$)
  2706.   values (-1, -170,system_grant.nextval, 1)
  2707. /
  2708. insert into sysauth$(grantee#, privilege#, sequence#, option$)
  2709.   values (-1, -171,system_grant.nextval, 1)
  2710. /
  2711. insert into sysauth$(grantee#, privilege#, sequence#, option$)
  2712.   values (-1, -172,system_grant.nextval, 1)
  2713. /
  2714. insert into sysauth$(grantee#, privilege#, sequence#, option$)
  2715.   values (-1, -173,system_grant.nextval, 1)
  2716. /
  2717. insert into sysauth$(grantee#, privilege#, sequence#, option$)
  2718.   values (-1, -174,system_grant.nextval, 1)
  2719. /
  2720. insert into sysauth$(grantee#, privilege#, sequence#, option$)
  2721.   values (-1, -175,system_grant.nextval, 1)
  2722. /
  2723. update sysauth$ set grantee#=(select user# from user$ where name='DBA')
  2724.   where grantee#=-1
  2725. /
  2726.  
  2727. # Add resource profiles
  2728. insert into resource_cost$ values (0, 0);
  2729. insert into resource_cost$ values (1, 0);
  2730. insert into resource_cost$ values (2, 0);
  2731. insert into resource_cost$ values (3, 0);
  2732. insert into resource_cost$ values (4, 0);
  2733. insert into resource_cost$ values (5, 0);
  2734. insert into resource_cost$ values (6, 0);
  2735. insert into resource_cost$ values (7, 0);
  2736. insert into resource_cost$ values (8, 0);
  2737. insert into resource_cost$ values (9, 0);
  2738.  
  2739. # under version six we can't ``create profile PUBLIC_DEFAULT''
  2740. # so we'll populate the tables ourselves
  2741. insert into profname$ values (0, 'DEFAULT');
  2742. #
  2743. insert into profile$ values (0, 0, 0, 2147483647);
  2744. insert into profile$ values (0, 1, 0, 2147483647);
  2745. insert into profile$ values (0, 2, 0, 2147483647);
  2746. insert into profile$ values (0, 3, 0, 2147483647);
  2747. insert into profile$ values (0, 4, 0, 2147483647);
  2748. insert into profile$ values (0, 5, 0, 2147483647);
  2749. insert into profile$ values (0, 6, 0, 2147483647);
  2750. insert into profile$ values (0, 7, 0, 2147483647);
  2751. insert into profile$ values (0, 8, 0, 2147483647);
  2752. insert into profile$ values (0, 9, 0, 0);
  2753.  
  2754. #
  2755. # m_bootstrap
  2756. #
  2757. insert into bootstrap$ values (1, 0, '7.0.7.0.0');
  2758.  
  2759. insert into bootstrap$ select 2, 0,
  2760.    'create rollback segment system storage ( initial ' || 
  2761.       seg$.iniexts * ts$.blocksize ||
  2762.    ' next ' || seg$.extsize * ts$.blocksize || 
  2763.    ' minextents ' || seg$.minexts ||
  2764.    ' maxextents ' || seg$.maxexts ||
  2765.    ' objno 0' ||
  2766.    ' extents ( file ' || seg$.file# ||
  2767.    ' block ' || seg$.block# || '))' 
  2768.    from sys.seg$, sys.undo$, sys.ts$
  2769.    where seg$.file# = undo$.file# and seg$.block# = undo$.block# and
  2770.          undo$.name = 'SYSTEM' and ts$.ts# = 0;
  2771.  
  2772. insert into bootstrap$ select 3, clu$.obj#,
  2773.    'create cluster c_obj# (obj# number)' ||
  2774.    ' pctfree ' || clu$.pctfree$ ||
  2775.    ' pctused ' || clu$.pctused$ ||
  2776.    ' initrans ' || clu$.initrans ||
  2777.    ' maxtrans ' || clu$.maxtrans ||
  2778.    ' storage ( initial ' || seg$.iniexts * ts$.blocksize ||
  2779.    ' next ' || seg$.extsize * ts$.blocksize ||
  2780.    ' minextents ' || seg$.minexts ||
  2781.    ' maxextents ' || seg$.maxexts ||
  2782.    ' pctincrease ' || seg$.extpct ||
  2783.    ' objno ' || clu$.obj# ||
  2784.    ' extents ( file ' || seg$.file# ||
  2785.    ' block ' || seg$.block# || '))' ||
  2786.    ' size ' || clu$.size$
  2787.    from sys.clu$, sys.seg$, sys.ts$, sys.obj$, sys.user$
  2788.    where seg$.file# = clu$.file# and seg$.block# = clu$.block# and
  2789.       clu$.obj# = obj$.obj# and obj$.name = 'C_OBJ#' and ts$.ts# = 0 and
  2790.       obj$.owner# = user$.user# and user$.name = 'MIGRATE';
  2791.  
  2792. insert into bootstrap$ select 4, ind$.obj#,
  2793.    'create index i_obj# on cluster c_obj#' ||
  2794.    ' pctfree ' || ind$.pctfree$ ||
  2795.    ' initrans ' || ind$.initrans ||
  2796.    ' maxtrans ' || ind$.maxtrans ||
  2797.    ' storage ( initial ' || seg$.iniexts * ts$.blocksize ||
  2798.    ' next ' || seg$.extsize * ts$.blocksize ||
  2799.    ' minextents ' || seg$.minexts ||
  2800.    ' maxextents ' || seg$.maxexts ||
  2801.    ' pctincrease ' || seg$.extpct ||
  2802.    ' objno ' || ind$.obj# ||
  2803.    ' extents ( file ' || seg$.file# ||
  2804.    ' block ' || seg$.block# || '))'
  2805.    from sys.ind$, sys.seg$, sys.ts$, sys.obj$, sys.user$
  2806.    where seg$.file# = ind$.file# and seg$.block# = ind$.block# and
  2807.       ind$.obj# = obj$.obj# and obj$.name = 'I_OBJ#' and ts$.ts# = 0 and
  2808.       obj$.owner# = user$.user# and user$.name = 'MIGRATE';
  2809.  
  2810. #^ create_table_clu(5, tab$, "c_obj#(obj#)",
  2811.     "create table tab$ 
  2812.      (obj#     number not null, 
  2813.       ts#      number not null,
  2814.       file#    number not null, 
  2815.       block#   number not null, 
  2816.       clu#     number,
  2817.       tab#     number, 
  2818.       cols     number not null, 
  2819.       clucols  number,
  2820.       pctfree$ number not null,
  2821.       pctused$ number not null,
  2822.       initrans number not null, 
  2823.       maxtrans number not null,
  2824.       modified number not null, 
  2825.       audit$   char(32) not null,
  2826.       rowcnt   number, 
  2827.       blkcnt   number, 
  2828.       empcnt   number,
  2829.       avgspc   number,
  2830.       chncnt   number, 
  2831.       avgrln   number,
  2832.       spare1   number,
  2833.       spare2   number)")
  2834.  
  2835. insert into bootstrap$ select 6, ind$.obj#,
  2836.    'create index i_tab1 on tab$(clu#)' ||
  2837.    ' pctfree ' || ind$.pctfree$ ||
  2838.    ' initrans ' || ind$.initrans ||
  2839.    ' maxtrans ' || ind$.maxtrans ||
  2840.    ' storage ( initial ' || seg$.iniexts * ts$.blocksize ||
  2841.    ' next ' || seg$.extsize * ts$.blocksize ||
  2842.    ' minextents ' || seg$.minexts ||
  2843.    ' maxextents ' || seg$.maxexts ||
  2844.    ' pctincrease ' || seg$.extpct ||
  2845.    ' objno ' || ind$.obj# ||
  2846.    ' extents ( file ' || seg$.file# ||
  2847.    ' block ' || seg$.block# || '))'
  2848.    from sys.ind$, sys.seg$, sys.ts$, sys.obj$, sys.user$
  2849.    where seg$.file# = ind$.file# and seg$.block# = ind$.block# and
  2850.       ind$.obj# = obj$.obj# and obj$.name = 'I_TAB1' and ts$.ts# = 0 and
  2851.       obj$.owner# = user$.user# and user$.name = 'MIGRATE';
  2852.  
  2853. #^ create_table_clu(7, clu$, "c_obj#(obj#)",
  2854.    "create table clu$ 
  2855.     (obj#     number not null, 
  2856.      ts#      number not null,
  2857.      file#    number not null, 
  2858.      block#   number not null,
  2859.      cols     number not null, 
  2860.      pctfree$ number not null,
  2861.      pctused$ number not null,
  2862.      initrans number not null, 
  2863.      maxtrans number not null,
  2864.      size$    number, 
  2865.      hashfunc char (30), 
  2866.      hashkeys number,
  2867.      func     number, 
  2868.      extind   number, 
  2869.      spare4   number, 
  2870.      spare5   number,
  2871.      spare6   number, 
  2872.      spare7   number, 
  2873.      spare8   number,
  2874.      spare9   number)")
  2875.  
  2876. insert into bootstrap$ select 8, clu$.obj#,
  2877.    'create cluster c_ts# (ts# number)' ||
  2878.    ' pctfree ' || clu$.pctfree$ ||
  2879.    ' pctused ' || clu$.pctused$ ||
  2880.    ' initrans ' || clu$.initrans ||
  2881.    ' maxtrans ' || clu$.maxtrans ||
  2882.    ' storage ( initial ' || seg$.iniexts * ts$.blocksize ||
  2883.    ' next ' || seg$.extsize * ts$.blocksize ||
  2884.    ' minextents ' || seg$.minexts ||
  2885.    ' maxextents 99' ||
  2886.    ' pctincrease ' || seg$.extpct ||
  2887.    ' objno ' || clu$.obj# ||
  2888.    ' extents ( file ' || seg$.file# ||
  2889.    ' block ' || seg$.block# || '))'
  2890.    from sys.clu$, sys.seg$, sys.ts$, sys.obj$, sys.user$
  2891.    where seg$.file# = clu$.file# and seg$.block# = clu$.block# and
  2892.       clu$.obj# = obj$.obj# and obj$.name = 'C_TS#' and ts$.ts# = 0 and
  2893.       obj$.owner# = user$.user# and user$.name = 'MIGRATE';
  2894.  
  2895. insert into bootstrap$ select 9, ind$.obj#,
  2896.    'create index i_ts# on cluster c_ts#' ||
  2897.    ' pctfree ' || ind$.pctfree$ ||
  2898.    ' initrans ' || ind$.initrans ||
  2899.    ' maxtrans ' || ind$.maxtrans ||
  2900.    ' storage ( initial ' || seg$.iniexts * ts$.blocksize ||
  2901.    ' next ' || seg$.extsize * ts$.blocksize ||
  2902.    ' minextents ' || seg$.minexts ||
  2903.    ' maxextents 99' ||
  2904.    ' pctincrease ' || seg$.extpct ||
  2905.    ' objno ' || ind$.obj# ||
  2906.    ' extents ( file ' || seg$.file# ||
  2907.    ' block ' || seg$.block# || '))'
  2908.    from sys.ind$, sys.seg$, sys.ts$, sys.obj$, sys.user$
  2909.    where seg$.file# = ind$.file# and seg$.block# = ind$.block# and
  2910.       ind$.obj# = obj$.obj# and obj$.name = 'I_TS#' and ts$.ts# = 0 and
  2911.       obj$.owner# = user$.user# and user$.name = 'MIGRATE';
  2912.  
  2913. insert into bootstrap$ select 10, clu$.obj#,
  2914.    'create cluster c_file#_block# (segfile# number, segblock# number)' ||
  2915.    ' pctfree ' || clu$.pctfree$ ||
  2916.    ' pctused ' || clu$.pctused$ ||
  2917.    ' initrans ' || clu$.initrans ||
  2918.    ' maxtrans ' || clu$.maxtrans ||
  2919.    ' storage ( initial ' || seg$.iniexts * ts$.blocksize ||
  2920.    ' next ' || seg$.extsize * ts$.blocksize ||
  2921.    ' minextents ' || seg$.minexts ||
  2922.    ' maxextents 99' || 
  2923.    ' pctincrease ' || seg$.extpct ||
  2924.    ' objno ' || clu$.obj# ||
  2925.    ' extents ( file ' || seg$.file# ||
  2926.    ' block ' || seg$.block# || '))' ||
  2927.    ' size ' || clu$.size$
  2928.    from sys.clu$, sys.seg$, sys.ts$, sys.obj$, sys.user$
  2929.    where seg$.file# = clu$.file# and seg$.block# = clu$.block# and
  2930.       clu$.obj# = obj$.obj# and obj$.name = 'C_FILE#_BLOCK#' and 
  2931.       ts$.ts# = 0 and obj$.owner# = user$.user# and user$.name = 'MIGRATE';
  2932.  
  2933. insert into bootstrap$ select 11, ind$.obj#,
  2934.    'create index i_file#_block# on cluster c_file#_block#' ||
  2935.    ' pctfree ' || ind$.pctfree$ ||
  2936.    ' initrans ' || ind$.initrans ||
  2937.    ' maxtrans ' || ind$.maxtrans ||
  2938.    ' storage ( initial ' || seg$.iniexts * ts$.blocksize ||
  2939.    ' next ' || seg$.extsize * ts$.blocksize ||
  2940.    ' minextents ' || seg$.minexts ||
  2941.    ' maxextents 99' ||
  2942.    ' pctincrease ' || seg$.extpct ||
  2943.    ' objno ' || ind$.obj# ||
  2944.    ' extents ( file ' || seg$.file# ||
  2945.    ' block ' || seg$.block# || '))'
  2946.    from sys.ind$, sys.seg$, sys.ts$, sys.obj$, sys.user$
  2947.    where seg$.file# = ind$.file# and seg$.block# = ind$.block# and
  2948.       ind$.obj# = obj$.obj# and obj$.name = 'I_FILE#_BLOCK#' and 
  2949.       ts$.ts# = 0 and obj$.owner# = user$.user# and user$.name = 'MIGRATE';
  2950.  
  2951.  
  2952. insert into bootstrap$ select 12, clu$.obj#,
  2953.    'create cluster c_user# (user# number)' ||
  2954.    ' pctfree ' || clu$.pctfree$ ||
  2955.    ' pctused ' || clu$.pctused$ ||
  2956.    ' initrans ' || clu$.initrans ||
  2957.    ' maxtrans ' || clu$.maxtrans ||
  2958.    ' storage ( initial ' || seg$.iniexts * ts$.blocksize ||
  2959.    ' next ' || seg$.extsize * ts$.blocksize ||
  2960.    ' minextents ' || seg$.minexts ||
  2961.    ' maxextents ' || seg$.maxexts ||
  2962.    ' pctincrease ' || seg$.extpct ||
  2963.    ' objno ' || clu$.obj# ||
  2964.    ' extents ( file ' || seg$.file# ||
  2965.    ' block ' || seg$.block# || '))' ||
  2966.    ' size ' || clu$.size$
  2967.    from sys.clu$, sys.seg$, sys.ts$, sys.obj$, sys.user$
  2968.    where seg$.file# = clu$.file# and seg$.block# = clu$.block# and
  2969.       clu$.obj# = obj$.obj# and obj$.name = 'C_USER#' and 
  2970.       ts$.ts# = 0 and obj$.owner# = user$.user# and user$.name = 'MIGRATE';
  2971.  
  2972. insert into bootstrap$ select 13, ind$.obj#,
  2973.    'create index i_user# on cluster c_user#' ||
  2974.    ' pctfree ' || ind$.pctfree$ ||
  2975.    ' initrans ' || ind$.initrans ||
  2976.    ' maxtrans ' || ind$.maxtrans ||
  2977.    ' storage ( initial ' || seg$.iniexts * ts$.blocksize ||
  2978.    ' next ' || seg$.extsize * ts$.blocksize ||
  2979.    ' minextents ' || seg$.minexts ||
  2980.    ' maxextents ' || seg$.maxexts ||
  2981.    ' pctincrease ' || seg$.extpct ||
  2982.    ' objno ' || ind$.obj# ||
  2983.    ' extents ( file ' || seg$.file# ||
  2984.    ' block ' || seg$.block# || '))'
  2985.    from sys.ind$, sys.seg$, sys.ts$, sys.obj$, sys.user$
  2986.    where seg$.file# = ind$.file# and seg$.block# = ind$.block# and
  2987.       ind$.obj# = obj$.obj# and obj$.name = 'I_USER#' and 
  2988.       ts$.ts# = 0 and obj$.owner# = user$.user# and user$.name = 'MIGRATE';
  2989.  
  2990. #^ create_table_clu(14, fet$, "c_ts#(ts#)",
  2991.    "create table fet$ 
  2992.      (ts#    number not null,
  2993.       file#  number not null, 
  2994.       block# number not null,
  2995.       length number not null)")
  2996.  
  2997. #^ create_table_clu(15, uet$,  "c_file#_block#(segfile#, segblock#)",
  2998.    "create table uet$ 
  2999.     (segfile#  number not null,
  3000.      segblock# number not null, 
  3001.      ext#      number not null,
  3002.      ts#       number not null, 
  3003.      file#     number not null,
  3004.      block#    number not null, 
  3005.      length    number not null)")
  3006.  
  3007. #^ create_table_clu(16, seg$, "c_file#_block#(file#, block#)",
  3008.    "create table seg$ 
  3009.     (file#   number not null,
  3010.      block#  number not null, 
  3011.      type    number not null,
  3012.      ts#     number not null, 
  3013.      blocks  number not null,
  3014.      extents number not null, 
  3015.      iniexts number not null,
  3016.      minexts number not null,
  3017.      maxexts number not null,
  3018.      extsize number not null,
  3019.      extpct  number not null,
  3020.      user#   number not null,
  3021.      lists   number,
  3022.      groups  number)")
  3023.  
  3024. #^ create_table(17, undo$, 
  3025.    "create table undo$ 
  3026.     (us#     number not null,
  3027.      name    char (30) not null, 
  3028.      user#   number not null,
  3029.      file#   number not null, 
  3030.      block#  number not null,
  3031.      scnbas  number not null, 
  3032.      scnwrp  number, 
  3033.      xactsqn number,
  3034.      undosqn number,
  3035.      inst#   number,
  3036.      status$ number not null)")
  3037.  
  3038. insert into bootstrap$ select 18, ind$.obj#,
  3039.    'create unique index i_undo1 on undo$(us#)' ||
  3040.    ' pctfree ' || ind$.pctfree$ ||
  3041.    ' initrans ' || ind$.initrans ||
  3042.    ' maxtrans ' || ind$.maxtrans ||
  3043.    ' storage ( initial ' || seg$.iniexts * ts$.blocksize ||
  3044.    ' next ' || seg$.extsize * ts$.blocksize ||
  3045.    ' minextents ' || seg$.minexts ||
  3046.    ' maxextents ' || seg$.maxexts ||
  3047.    ' pctincrease ' || seg$.extpct ||
  3048.    ' objno ' || ind$.obj# ||
  3049.    ' extents ( file ' || seg$.file# ||
  3050.    ' block ' || seg$.block# || '))'
  3051.    from sys.ind$, sys.seg$, sys.ts$, sys.obj$, sys.user$
  3052.    where seg$.file# = ind$.file# and seg$.block# = ind$.block# and
  3053.       ind$.obj# = obj$.obj# and obj$.name = 'I_UNDO1' and ts$.ts# = 0 and
  3054.       obj$.owner# = user$.user# and user$.name = 'MIGRATE';
  3055.  
  3056. #^ create_table_clu(19, ts$, "c_ts#(ts#)",
  3057.    "create table ts$ 
  3058.     (ts#        number not null,
  3059.      name       char (30) not null,
  3060.      owner#     number not null,
  3061.      online$    number not null, 
  3062.      undofile#  number,
  3063.      undoblock# number, 
  3064.      blocksize  number not null,
  3065.      inc#       number not null, 
  3066.      scnwrp     number,
  3067.      scnbas     number, 
  3068.      dflminext  number not null,
  3069.      dflmaxext  number not null, 
  3070.      dflinit    number not null,
  3071.      dflincr    number not null, 
  3072.      dflextpct  number not null)")
  3073.  
  3074. #^ create_table(20, file$,
  3075.    "create table file$ 
  3076.     (file#   number not null,
  3077.      status$ number not null, 
  3078.      blocks  number not null,
  3079.      ts#     number not null)")
  3080.  
  3081. insert into bootstrap$ select 21, ind$.obj#,
  3082.    'create unique index i_file1 on file$(file#)' ||
  3083.    ' pctfree ' || ind$.pctfree$ ||
  3084.    ' initrans ' || ind$.initrans ||
  3085.    ' maxtrans ' || ind$.maxtrans ||
  3086.    ' storage ( initial ' || seg$.iniexts * ts$.blocksize ||
  3087.    ' next ' || seg$.extsize * ts$.blocksize ||
  3088.    ' minextents ' || seg$.minexts ||
  3089.    ' maxextents ' || seg$.maxexts ||
  3090.    ' pctincrease ' || seg$.extpct ||
  3091.    ' objno ' || ind$.obj# ||
  3092.    ' extents ( file ' || seg$.file# ||
  3093.    ' block ' || seg$.block# || '))'
  3094.    from sys.ind$, sys.seg$, sys.ts$, sys.obj$, sys.user$
  3095.    where seg$.file# = ind$.file# and seg$.block# = ind$.block# and
  3096.       ind$.obj# = obj$.obj# and obj$.name = 'I_FILE1' and ts$.ts# = 0 and
  3097.       obj$.owner# = user$.user# and user$.name = 'MIGRATE';
  3098.  
  3099. #^ create_table(22, obj$, 
  3100.    "create table obj$ 
  3101.     (obj#        number not null,
  3102.      owner#      number not null, 
  3103.      name        char (30) not null,
  3104.      namespace   number not null, 
  3105.      type        number not null,
  3106.      ctime       date not null,
  3107.      mtime       date not null, 
  3108.      stime       date not null,
  3109.      status      number not null, 
  3110.      remoteowner char (30),
  3111.      linkname    char (128))")
  3112.  
  3113. insert into bootstrap$ select 23, ind$.obj#,
  3114.    'create unique index i_obj1 on obj$(obj#)' ||
  3115.    ' pctfree ' || ind$.pctfree$ ||
  3116.    ' initrans ' || ind$.initrans ||
  3117.    ' maxtrans ' || ind$.maxtrans ||
  3118.    ' storage ( initial ' || seg$.iniexts * ts$.blocksize ||
  3119.    ' next ' || seg$.extsize * ts$.blocksize ||
  3120.    ' minextents ' || seg$.minexts ||
  3121.    ' maxextents ' || seg$.maxexts ||
  3122.    ' pctincrease ' || seg$.extpct ||
  3123.    ' objno ' || ind$.obj# ||
  3124.    ' extents ( file ' || seg$.file# ||
  3125.    ' block ' || seg$.block# || '))'
  3126.    from sys.ind$, sys.seg$, sys.ts$, sys.obj$, sys.user$
  3127.    where seg$.file# = ind$.file# and seg$.block# = ind$.block# and
  3128.       ind$.obj# = obj$.obj# and obj$.name = 'I_OBJ1' and ts$.ts# = 0 and
  3129.       obj$.owner# = user$.user# and user$.name = 'MIGRATE';
  3130.  
  3131. insert into bootstrap$ select 24, ind$.obj#,
  3132.    'create unique index i_obj2 on obj$(owner#, name, namespace,' ||
  3133.    ' remoteowner, linkname)' ||
  3134.    ' pctfree ' || ind$.pctfree$ ||
  3135.    ' initrans ' || ind$.initrans ||
  3136.    ' maxtrans ' || ind$.maxtrans ||
  3137.    ' storage ( initial ' || seg$.iniexts * ts$.blocksize ||
  3138.    ' next ' || seg$.extsize * ts$.blocksize ||
  3139.    ' minextents ' || seg$.minexts ||
  3140.    ' maxextents ' || seg$.maxexts ||
  3141.    ' pctincrease ' || seg$.extpct ||
  3142.    ' objno ' || ind$.obj# ||
  3143.    ' extents ( file ' || seg$.file# ||
  3144.    ' block ' || seg$.block# || '))'
  3145.    from sys.ind$, sys.seg$, sys.ts$, sys.obj$, sys.user$
  3146.    where seg$.file# = ind$.file# and seg$.block# = ind$.block# and
  3147.       ind$.obj# = obj$.obj# and obj$.name = 'I_OBJ2' and ts$.ts# = 0 and
  3148.       obj$.owner# = user$.user# and user$.name = 'MIGRATE';
  3149.  
  3150. #^ create_table_clu(25, ind$, "c_obj#(bo#)",
  3151.    "create table ind$ 
  3152.     (obj#      number not null,
  3153.      ts#       number not null, 
  3154.      file#     number not null,
  3155.      block#    number not null, 
  3156.      bo#       number not null,
  3157.      cols      number not null, 
  3158.      pctfree$  number not null,
  3159.      initrans  number not null, 
  3160.      maxtrans  number not null,
  3161.      compress$ number not null, 
  3162.      unique$   number not null,
  3163.      blevel    number, 
  3164.      leafcnt   number, 
  3165.      distkey   number,
  3166.      lblkkey   number, 
  3167.      dblkkey   number, 
  3168.      clufac    number, 
  3169.      spare7    number,
  3170.      spare8    number)")
  3171.  
  3172. insert into bootstrap$ select 26, ind$.obj#,
  3173.    'create unique index i_ind1 on ind$(obj#)' ||
  3174.    ' pctfree ' || ind$.pctfree$ ||
  3175.    ' initrans ' || ind$.initrans ||
  3176.    ' maxtrans ' || ind$.maxtrans ||
  3177.    ' storage ( initial ' || seg$.iniexts * ts$.blocksize ||
  3178.    ' next ' || seg$.extsize * ts$.blocksize ||
  3179.    ' minextents ' || seg$.minexts ||
  3180.    ' maxextents ' || seg$.maxexts ||
  3181.    ' pctincrease ' || seg$.extpct ||
  3182.    ' objno ' || ind$.obj# ||
  3183.    ' extents ( file ' || seg$.file# ||
  3184.    ' block ' || seg$.block# || '))'
  3185.    from sys.ind$, sys.seg$, sys.ts$, sys.obj$, sys.user$
  3186.    where seg$.file# = ind$.file# and seg$.block# = ind$.block# and
  3187.       ind$.obj# = obj$.obj# and obj$.name = 'I_IND1' and ts$.ts# = 0 and
  3188.       obj$.owner# = user$.user# and user$.name = 'MIGRATE';
  3189.  
  3190.  
  3191. #^ create_table_clu(27, icol$, "c_obj#(bo#)",
  3192.    "create table icol$ 
  3193.     (obj#         number not null,
  3194.      bo#          number not null, 
  3195.      col#         number not null,
  3196.      pos#         number not null,
  3197.      segcol#      number not null,
  3198.      segcollength number not null, 
  3199.      offset        number not null)")
  3200.  
  3201. insert into bootstrap$ select 28, ind$.obj#,
  3202.    'create  index i_icol1 on icol$(obj#)' ||
  3203.    ' pctfree ' || ind$.pctfree$ ||
  3204.    ' initrans ' || ind$.initrans ||
  3205.    ' maxtrans ' || ind$.maxtrans ||
  3206.    ' storage ( initial ' || seg$.iniexts * ts$.blocksize ||
  3207.    ' next ' || seg$.extsize * ts$.blocksize ||
  3208.    ' minextents ' || seg$.minexts ||
  3209.    ' maxextents ' || seg$.maxexts ||
  3210.    ' pctincrease ' || seg$.extpct ||
  3211.    ' objno ' || ind$.obj# ||
  3212.    ' extents ( file ' || seg$.file# ||
  3213.    ' block ' || seg$.block# || '))'
  3214.    from sys.ind$, sys.seg$, sys.ts$, sys.obj$, sys.user$
  3215.    where seg$.file# = ind$.file# and seg$.block# = ind$.block# and
  3216.       ind$.obj# = obj$.obj# and obj$.name = 'I_ICOL1' and ts$.ts# = 0 and
  3217.       obj$.owner# = user$.user# and user$.name = 'MIGRATE';
  3218.  
  3219. #^ create_table_clu(29, col$, "c_obj#(obj#)",
  3220.    "create table col$ 
  3221.     (obj#          number not null,
  3222.      col#          number not null, 
  3223.      segcol#       number not null,
  3224.      segcollength  number not null, 
  3225.      offset        number not null,
  3226.      name          char (30) not null, 
  3227.      type#         number not null,
  3228.      length        number not null, 
  3229.      fixedstorage  number not null,
  3230.      precision     number, 
  3231.      scale         number,
  3232.      null$         number not null,
  3233.      distcnt       number, 
  3234.      lowval        raw(32),
  3235.      hival         raw(32), 
  3236.      deflength     number,
  3237.      default$      long,
  3238.      spare2        number, 
  3239.      spare3        number)")
  3240.  
  3241. insert into bootstrap$ select 30, ind$.obj#,
  3242.    'create unique index i_col1 on col$(obj#, name)' ||
  3243.    ' pctfree ' || ind$.pctfree$ ||
  3244.    ' initrans ' || ind$.initrans ||
  3245.    ' maxtrans ' || ind$.maxtrans ||
  3246.    ' storage ( initial ' || seg$.iniexts * ts$.blocksize ||
  3247.    ' next ' || seg$.extsize * ts$.blocksize ||
  3248.    ' minextents ' || seg$.minexts ||
  3249.    ' maxextents ' || seg$.maxexts ||
  3250.    ' pctincrease ' || seg$.extpct ||
  3251.    ' objno ' || ind$.obj# ||
  3252.    ' extents ( file ' || seg$.file# ||
  3253.    ' block ' || seg$.block# || '))'
  3254.    from sys.ind$, sys.seg$, sys.ts$, sys.obj$, sys.user$
  3255.    where seg$.file# = ind$.file# and seg$.block# = ind$.block# and
  3256.       ind$.obj# = obj$.obj# and obj$.name = 'I_COL1' and ts$.ts# = 0 and
  3257.       obj$.owner# = user$.user# and user$.name = 'MIGRATE';
  3258.  
  3259. insert into bootstrap$ select 31, ind$.obj#,
  3260.    'create unique index i_col2 on col$(obj#, col#)' ||
  3261.    ' pctfree ' || ind$.pctfree$ ||
  3262.    ' initrans ' || ind$.initrans ||
  3263.    ' maxtrans ' || ind$.maxtrans ||
  3264.    ' storage ( initial ' || seg$.iniexts * ts$.blocksize ||
  3265.    ' next ' || seg$.extsize * ts$.blocksize ||
  3266.    ' minextents ' || seg$.minexts ||
  3267.    ' maxextents ' || seg$.maxexts ||
  3268.    ' pctincrease ' || seg$.extpct ||
  3269.    ' objno ' || ind$.obj# ||
  3270.    ' extents ( file ' || seg$.file# ||
  3271.    ' block ' || seg$.block# || '))'
  3272.    from sys.ind$, sys.seg$, sys.ts$, sys.obj$, sys.user$
  3273.    where seg$.file# = ind$.file# and seg$.block# = ind$.block# and
  3274.       ind$.obj# = obj$.obj# and obj$.name = 'I_COL2' and ts$.ts# = 0 and
  3275.       obj$.owner# = user$.user# and user$.name = 'MIGRATE';
  3276.  
  3277.  
  3278. #^ create_table_clu(32, user$, "c_user#(user#)",
  3279.    "create table user$ 
  3280.     (user#     number not null,
  3281.      name      char (30) not null,
  3282.      type      number not null,
  3283.      password  char (30), 
  3284.      datats#   number not null,
  3285.      tempts#   number not null, 
  3286.      ctime     date not null,
  3287.      ptime     date, 
  3288.      resource$ number not null,
  3289.      audit$    char (32),
  3290.      defrole   number not null,
  3291.      spare1    number,
  3292.      spare2    number)")
  3293.  
  3294. insert into bootstrap$ select 33, ind$.obj#,
  3295.    'create unique index i_user1 on user$(name)' ||
  3296.    ' pctfree ' || ind$.pctfree$ ||
  3297.    ' initrans ' || ind$.initrans ||
  3298.    ' maxtrans ' || ind$.maxtrans ||
  3299.    ' storage ( initial ' || seg$.iniexts * ts$.blocksize ||
  3300.    ' next ' || seg$.extsize * ts$.blocksize ||
  3301.    ' minextents ' || seg$.minexts ||
  3302.    ' maxextents ' || seg$.maxexts ||
  3303.    ' pctincrease ' || seg$.extpct ||
  3304.    ' objno ' || ind$.obj# ||
  3305.    ' extents ( file ' || seg$.file# ||
  3306.    ' block ' || seg$.block# || '))'
  3307.    from sys.ind$, sys.seg$, sys.ts$, sys.obj$, sys.user$
  3308.    where seg$.file# = ind$.file# and seg$.block# = ind$.block# and
  3309.       ind$.obj# = obj$.obj# and obj$.name = 'I_USER1' and ts$.ts# = 0 and
  3310.       obj$.owner# = user$.user# and user$.name = 'MIGRATE';
  3311.  
  3312. #^ create_table(34, con$, 
  3313.    "create table con$ 
  3314.     (owner# number not null,
  3315.      name   char (30) not null, 
  3316.      con#   number not null,
  3317.      spare1 number)")
  3318.  
  3319. insert into bootstrap$ select 35, ind$.obj#,
  3320.    'create unique index i_con1 on con$(owner#, name)' ||
  3321.    ' pctfree ' || ind$.pctfree$ ||
  3322.    ' initrans ' || ind$.initrans ||
  3323.    ' maxtrans ' || ind$.maxtrans ||
  3324.    ' storage ( initial ' || seg$.iniexts * ts$.blocksize ||
  3325.    ' next ' || seg$.extsize * ts$.blocksize ||
  3326.    ' minextents ' || seg$.minexts ||
  3327.    ' maxextents ' || seg$.maxexts ||
  3328.    ' pctincrease ' || seg$.extpct ||
  3329.    ' objno ' || ind$.obj# ||
  3330.    ' extents ( file ' || seg$.file# ||
  3331.    ' block ' || seg$.block# || '))'
  3332.    from sys.ind$, sys.seg$, sys.ts$, sys.obj$, sys.user$
  3333.    where seg$.file# = ind$.file# and seg$.block# = ind$.block# and
  3334.       ind$.obj# = obj$.obj# and obj$.name = 'I_CON1' and ts$.ts# = 0 and
  3335.       obj$.owner# = user$.user# and user$.name = 'MIGRATE';
  3336.  
  3337. insert into bootstrap$ select 36, ind$.obj#,
  3338.    'create unique index i_con2 on con$(con#)' ||
  3339.    ' pctfree ' || ind$.pctfree$ ||
  3340.    ' initrans ' || ind$.initrans ||
  3341.    ' maxtrans ' || ind$.maxtrans ||
  3342.    ' storage ( initial ' || seg$.iniexts * ts$.blocksize ||
  3343.    ' next ' || seg$.extsize * ts$.blocksize ||
  3344.    ' minextents ' || seg$.minexts ||
  3345.    ' maxextents ' || seg$.maxexts ||
  3346.    ' pctincrease ' || seg$.extpct ||
  3347.    ' objno ' || ind$.obj# ||
  3348.    ' extents ( file ' || seg$.file# ||
  3349.    ' block ' || seg$.block# || '))'
  3350.    from sys.ind$, sys.seg$, sys.ts$, sys.obj$, sys.user$
  3351.    where seg$.file# = ind$.file# and seg$.block# = ind$.block# and
  3352.       ind$.obj# = obj$.obj# and obj$.name = 'I_CON2' and ts$.ts# = 0 and
  3353.       obj$.owner# = user$.user# and user$.name = 'MIGRATE';
  3354.  
  3355.  
  3356. insert into bootstrap$ select 37, clu$.obj#,
  3357.    'create cluster c_cobj# (obj# number)' ||
  3358.    ' pctfree ' || clu$.pctfree$ ||
  3359.    ' pctused ' || clu$.pctused$ ||
  3360.    ' initrans ' || clu$.initrans ||
  3361.    ' maxtrans ' || clu$.maxtrans ||
  3362.    ' storage ( initial ' || seg$.iniexts * ts$.blocksize ||
  3363.    ' next ' || seg$.extsize * ts$.blocksize ||
  3364.    ' minextents ' || seg$.minexts ||
  3365.    ' maxextents ' || seg$.maxexts ||
  3366.    ' pctincrease ' || seg$.extpct ||
  3367.    ' objno ' || clu$.obj# ||
  3368.    ' extents ( file ' || seg$.file# ||
  3369.    ' block ' || seg$.block# || '))' ||
  3370.    ' size ' || clu$.size$
  3371.    from sys.clu$, sys.seg$, sys.ts$, sys.obj$, sys.user$
  3372.    where seg$.file# = clu$.file# and seg$.block# = clu$.block# and
  3373.       clu$.obj# = obj$.obj# and obj$.name = 'C_COBJ#' and 
  3374.       ts$.ts# = 0 and obj$.owner# = user$.user# and user$.name = 'MIGRATE';
  3375.  
  3376. insert into bootstrap$ select 38, ind$.obj#,
  3377.    'create index i_cobj# on cluster c_cobj#' ||
  3378.    ' pctfree ' || ind$.pctfree$ ||
  3379.    ' initrans ' || ind$.initrans ||
  3380.    ' maxtrans ' || ind$.maxtrans ||
  3381.    ' storage ( initial ' || seg$.iniexts * ts$.blocksize ||
  3382.    ' next ' || seg$.extsize * ts$.blocksize ||
  3383.    ' minextents ' || seg$.minexts ||
  3384.    ' maxextents ' || seg$.maxexts ||
  3385.    ' pctincrease ' || seg$.extpct ||
  3386.    ' objno ' || ind$.obj# ||
  3387.    ' extents ( file ' || seg$.file# ||
  3388.    ' block ' || seg$.block# || '))'
  3389.    from sys.ind$, sys.seg$, sys.ts$, sys.obj$, sys.user$
  3390.    where seg$.file# = ind$.file# and seg$.block# = ind$.block# and
  3391.       ind$.obj# = obj$.obj# and obj$.name = 'I_COBJ#' and 
  3392.       ts$.ts# = 0 and obj$.owner# = user$.user# and user$.name = 'MIGRATE';
  3393.  
  3394. #^ create_table_clu(39, cdef$, "c_cobj#(obj#)",
  3395.    "create table cdef$ 
  3396.     (con#       number not null,
  3397.      obj#       number not null, 
  3398.      cols       number, 
  3399.      type       number not null,
  3400.      robj#      number, 
  3401.      rcon#      number,
  3402.      rrules     char (3), 
  3403.      match      number, 
  3404.      refact     number,
  3405.      enabled    number, 
  3406.      condlength number, 
  3407.      condition  long,
  3408.      spare1     number)")
  3409.  
  3410. insert into bootstrap$ select 40, ind$.obj#,
  3411.    'create unique index i_cdef1 on cdef$(con#)' ||
  3412.    ' pctfree ' || ind$.pctfree$ ||
  3413.    ' initrans ' || ind$.initrans ||
  3414.    ' maxtrans ' || ind$.maxtrans ||
  3415.    ' storage ( initial ' || seg$.iniexts * ts$.blocksize ||
  3416.    ' next ' || seg$.extsize * ts$.blocksize ||
  3417.    ' minextents ' || seg$.minexts ||
  3418.    ' maxextents ' || seg$.maxexts ||
  3419.    ' pctincrease ' || seg$.extpct ||
  3420.    ' objno ' || ind$.obj# ||
  3421.    ' extents ( file ' || seg$.file# ||
  3422.    ' block ' || seg$.block# || '))'
  3423.    from sys.ind$, sys.seg$, sys.ts$, sys.obj$, sys.user$
  3424.    where seg$.file# = ind$.file# and seg$.block# = ind$.block# and
  3425.       ind$.obj# = obj$.obj# and obj$.name = 'I_CDEF1' and ts$.ts# = 0 and
  3426.       obj$.owner# = user$.user# and user$.name = 'MIGRATE';
  3427.  
  3428. insert into bootstrap$ select 41, ind$.obj#,
  3429.    'create index i_cdef2 on cdef$(obj#)' ||
  3430.    ' pctfree ' || ind$.pctfree$ ||
  3431.    ' initrans ' || ind$.initrans ||
  3432.    ' maxtrans ' || ind$.maxtrans ||
  3433.    ' storage ( initial ' || seg$.iniexts * ts$.blocksize ||
  3434.    ' next ' || seg$.extsize * ts$.blocksize ||
  3435.    ' minextents ' || seg$.minexts ||
  3436.    ' maxextents ' || seg$.maxexts ||
  3437.    ' pctincrease ' || seg$.extpct ||
  3438.    ' objno ' || ind$.obj# ||
  3439.    ' extents ( file ' || seg$.file# ||
  3440.    ' block ' || seg$.block# || '))'
  3441.    from sys.ind$, sys.seg$, sys.ts$, sys.obj$, sys.user$
  3442.    where seg$.file# = ind$.file# and seg$.block# = ind$.block# and
  3443.       ind$.obj# = obj$.obj# and obj$.name = 'I_CDEF2' and ts$.ts# = 0 and
  3444.       obj$.owner# = user$.user# and user$.name = 'MIGRATE';
  3445.  
  3446. insert into bootstrap$ select 42, ind$.obj#,
  3447.    'create index i_cdef3 on cdef$(robj#)' ||
  3448.    ' pctfree ' || ind$.pctfree$ ||
  3449.    ' initrans ' || ind$.initrans ||
  3450.    ' maxtrans ' || ind$.maxtrans ||
  3451.    ' storage ( initial ' || seg$.iniexts * ts$.blocksize ||
  3452.    ' next ' || seg$.extsize * ts$.blocksize ||
  3453.    ' minextents ' || seg$.minexts ||
  3454.    ' maxextents ' || seg$.maxexts ||
  3455.    ' pctincrease ' || seg$.extpct ||
  3456.    ' objno ' || ind$.obj# ||
  3457.    ' extents ( file ' || seg$.file# ||
  3458.    ' block ' || seg$.block# || '))'
  3459.    from sys.ind$, sys.seg$, sys.ts$, sys.obj$, sys.user$
  3460.    where seg$.file# = ind$.file# and seg$.block# = ind$.block# and
  3461.       ind$.obj# = obj$.obj# and obj$.name = 'I_CDEF3' and ts$.ts# = 0 and
  3462.       obj$.owner# = user$.user# and user$.name = 'MIGRATE';
  3463.  
  3464. #^ create_table_clu(43, ccol$, "c_cobj#(obj#)",
  3465.    "create table ccol$ 
  3466.     (con# number not null,
  3467.      obj# number not null, 
  3468.      col# number not null, 
  3469.      pos# number,
  3470.      spare1 number)")
  3471.  
  3472. insert into bootstrap$ select 44, ind$.obj#,
  3473.    'create unique index i_ccol1 on ccol$(con#, col#)' ||
  3474.    ' pctfree ' || ind$.pctfree$ ||
  3475.    ' initrans ' || ind$.initrans ||
  3476.    ' maxtrans ' || ind$.maxtrans ||
  3477.    ' storage ( initial ' || seg$.iniexts * ts$.blocksize ||
  3478.    ' next ' || seg$.extsize * ts$.blocksize ||
  3479.    ' minextents ' || seg$.minexts ||
  3480.    ' maxextents ' || seg$.maxexts ||
  3481.    ' pctincrease ' || seg$.extpct ||
  3482.    ' objno ' || ind$.obj# ||
  3483.    ' extents ( file ' || seg$.file# ||
  3484.    ' block ' || seg$.block# || '))'
  3485.    from sys.ind$, sys.seg$, sys.ts$, sys.obj$, sys.user$
  3486.    where seg$.file# = ind$.file# and seg$.block# = ind$.block# and
  3487.       ind$.obj# = obj$.obj# and obj$.name = 'I_CCOL1' and ts$.ts# = 0 and
  3488.       obj$.owner# = user$.user# and user$.name = 'MIGRATE';
  3489.  
  3490. #^ create_table(45, bootstrap$,
  3491.    "create table bootstrap$ 
  3492.     (line# number not null,
  3493.      obj#     number not null, 
  3494.      sql_text long not null)")
  3495.  
  3496. #              
  3497. # m_misc
  3498. #
  3499.  
  3500. ## the following changes are for epeeler and deal with
  3501. ## how not null column constraints are handled
  3502.  
  3503. ## update the cdef$ table first to make the NULL$ constraints type 7
  3504. update cdef$ set type=7 where
  3505.   con# in (select abs(null$) from col$ where null$>0 or
  3506.        null$ < 0);
  3507.  
  3508. ## update the col$ for the enables NOT NULL column constraints
  3509. update col$ set null$=1 where null$ > 0;
  3510.  
  3511. ## update the col$ table for the disables NOT NULL column constraints
  3512. update col$ set null$=0 where null$ < 0;
  3513.  
  3514. ## update the col$ table for the enabled primary keys
  3515. update col$ c set null$=null$+1 where
  3516. (obj#,col#) = (select cc.obj#,cc.col# from ccol$ cc,cdef$ cd
  3517.            where cc.con#=cd.con# and cd.type=2 and
  3518.            enabled is not null and c.obj#=cc.obj# and
  3519.            c.col#=cc.col#);
  3520.  
  3521.  
  3522. #
  3523. # convert v6 nls parameters into their v7 equivalent
  3524. #
  3525.  
  3526. #^ convert_nls()
  3527.  
  3528. #
  3529. # convert v6 longs into v7 varchar2 (2000);
  3530. #
  3531.  
  3532. update col$ set type# = 1, length = 2000 where name = 'SQL_TEXT' and
  3533.    obj# = (select obj$.obj# from obj$ where obj$.name = 'BOOTSTRAP$');
  3534.  
  3535. update col$ set type# = 1, length = 2000 where name = 'SOURCE' and
  3536.    obj# = (select obj$.obj# from obj$ where obj$.name = 'SOURCE$');
  3537.  
  3538. update col$ set type# = 1, length = 2000 where name = 'TEXT' and
  3539.    obj# = (select obj$.obj# from obj$ where obj$.name = 'ERROR$');
  3540.  
  3541. update col$ set type# = 1, length = 2000 where name = 'DEFINITION' and
  3542.    obj# = (select obj$.obj# from obj$ where obj$.name = 'TRIGGER$');
  3543.  
  3544. update col$ set type# = 1, length = 2000 where name = 'WHENCLAUSE' and
  3545.    obj# = (select obj$.obj# from obj$ where obj$.name = 'TRIGGER$');
  3546.  
  3547. update col$ set type# = 1, length = 2000 where name = 'COMMENT$TEXT' and
  3548.    obj# = (select obj$.obj# from obj$ where obj$.name = 'AUD$' and 
  3549.            obj$.owner# = (select user$.user# from user$ 
  3550.                                  where user$.name = 'MIGRATE'));
  3551.  
  3552. update col$ set type# = 1, length = 2000 where name = 'COMMENT$' and
  3553.    obj# = (select obj$.obj# from obj$ where obj$.name = 'COM$' and 
  3554.            obj$.owner# = (select user$.user# from user$ 
  3555.                                  where user$.name = 'MIGRATE'));
  3556.  
  3557. update col$ set type# = 1, length = 2000 where name = 'QUERY_TXT' and
  3558.    obj# = (select obj$.obj# from obj$ where obj$.name = 'SNAP$');
  3559.  
  3560. update col$ set type# = 1, length = 2000 where name = 'WHAT' and
  3561.    obj# = (select obj$.obj# from obj$ where obj$.name = 'JOB$');
  3562.  
  3563. update col$ set type# = 1, length = 2000 where name = 'NLSENV' and
  3564.    obj# = (select obj$.obj# from obj$ where obj$.name = 'JOB$');
  3565.  
  3566. update col$ set type# = 1, length = 2000 where name = 'CHARENV' and
  3567.    obj# = (select obj$.obj# from obj$ where obj$.name = 'JOB$');
  3568.  
  3569. #
  3570. # convert v6 longs to pidl types
  3571. #
  3572. #sb4 = type 29
  3573. #ub2 = type 25
  3574.  
  3575. update col$ set type# = 29 where name = 'PIECE' and
  3576.    obj# = (select obj$.obj# from obj$ where obj$.name = 'IDL_SB4$');
  3577.  
  3578. update col$ set type# = 25 where name = 'PIECE' and
  3579.    obj# = (select obj$.obj# from obj$ where obj$.name = 'IDL_UB2$');
  3580.  
  3581. #
  3582. #  swap the ownership of the data dictionary in
  3583. #  migrate's copy.
  3584. #  use _NEXT_USER as the temp for swapping.
  3585. #
  3586. # _NEXT_USER <- SYS
  3587. update obj$ set owner# = (select user# from user$ where name = '_NEXT_USER')
  3588.    where owner# = (select user# from user$ where name = 'SYS') and
  3589.          name in (select name from sys.v7_objects where type = 'M' or 
  3590.                                 type = 'P' or
  3591.                             type = 'O');
  3592. #
  3593. # SYS <- MIGRATE
  3594. #
  3595. update obj$ set owner# = (select user# from user$ where name = 'SYS')
  3596.    where owner# = (select user# from user$ where name = 'MIGRATE');
  3597. #
  3598. # MIGRATE <- _NEXT_USER
  3599. #
  3600. update obj$ set owner# = (select user# from user$ where name = 'MIGRATE')
  3601.    where owner# = (select user# from user$ where name = '_NEXT_USER');
  3602. #
  3603. #  swap SYS and MIGRATE in col GRANTOR# in table objauth$
  3604. #
  3605. update objauth$ set grantor# = 
  3606.   (select user# from user$ where name = '_NEXT_USER') 
  3607.   where grantor# = (select user# from user$ where name = 'SYS');
  3608. update objauth$ set grantor# = 
  3609.    (select user# from user$ where name = 'SYS')
  3610.    where grantor# = (select user# from user$ where name = 'MIGRATE');
  3611. update objauth$ set grantor# = 
  3612.    (select user# from user$ where name = 'MIGRATE')
  3613.    where grantor# = (select user# from user$ where name = '_NEXT_USER');
  3614. #
  3615. # invalidate all the views so they get recreated in v7
  3616. #
  3617. update obj$ set status = 5 where type = 4;
  3618. #
  3619. #  change migrate's password.  after sys and migrate change
  3620. #  tables, one will no longer be able to log in as migrate.
  3621. #
  3622. update user$ set user$.password = 'no login' where user$.name = 'MIGRATE'; 
  3623.  
  3624. #
  3625. #  Now populate the space management tables.  This must be handled
  3626. #  *very* delicately.  We cannot allow any space operations to
  3627. #  occur while we are doing this.  The c_file#_block# and c_ts# cluster
  3628. #  and their indexes were created with maxextents = 1, so they cannot
  3629. #  extend.  We must also be careful not to issue any SQL that uses
  3630. #  a sort, as they may cause a temp table to extend.  We also must
  3631. #  get a consistant snapshot of all 3 tables, so we lock them
  3632. #  all in exclusive mode.  This prevents SMON from doing any
  3633. #  temp segment cleanup while we copy the tables.
  3634. #  We also cannot allow the system rollback segment to extend while all 
  3635. #  this is going on, so we freeze it at its current size.
  3636. #
  3637.  
  3638. #^ connect (maint, internal)
  3639. #^ freeze_rb()
  3640. #^ connect (migrate, migrate)
  3641.  
  3642. #^ run ("lock table fet$ in exclusive mode")
  3643. #^ run ("lock table seg$ in exclusive mode")
  3644. #^ run ("lock table uet$ in exclusive mode")
  3645.  
  3646. #
  3647. #  populate seg$
  3648. #
  3649. #^ run ("insert into seg$ 
  3650.     select file#, block#, type, ts#, blocks, extents, 
  3651.     iniexts, minexts, maxexts, extsize, extpct, user#, NULL, NULL 
  3652.     from sys.seg$")
  3653. #
  3654. #  populate fet$
  3655. #
  3656. #^ run ("insert into fet$ select * from sys.fet$")
  3657. #
  3658. #  populate uet$;
  3659. #
  3660. #^ run ("insert into uet$ select * from sys.uet$")
  3661. #
  3662. #  convert segment owners in seg$
  3663. #
  3664. update seg$ set user# = (select user# from user$ where name = 'SYS')
  3665.   where user# = (select user# from user$ where name = 'MIGRATE');
  3666. #
  3667. #  all rollback segments in v7 have pctincrease = 0
  3668. #
  3669. update seg$ s set s.extpct = 0 where exists
  3670.  (select u.file#, u.block# from undo$ u
  3671.     where u.file# = s.file# and u.block# = s.block#);  
  3672. #
  3673. #  set maxexts to 99 for those space management objects that we created
  3674. #  with maxextents 1
  3675. #
  3676. update seg$ s set s.maxexts = 99
  3677.   where s.user# = (select user# from user$ where name = 'SYS')
  3678.     and exists (select o.obj# from obj$ o, clu$ c
  3679.         where (o.name = 'C_FILE#_BLOCK#' or o.name = 'C_TS#')
  3680.           and o.obj# = c.obj#
  3681.           and o.owner# = s.user#
  3682.           and c.file# = s.file# and c.block# = s.block#);
  3683.  
  3684. update seg$ s set s.maxexts = 99
  3685.   where s.user# = (select user# from user$ where name = 'SYS')
  3686.     and exists (select o.obj# from obj$ o, ind$ i
  3687.         where (o.name = 'I_FILE#_BLOCK#' or o.name = 'I_TS#')
  3688.           and o.obj# = i.obj#
  3689.           and o.owner# = s.user#
  3690.           and i.file# = s.file# and i.block# = s.block#);
  3691. update seg$ s set s.maxexts = 99
  3692.   where (s.file#, s.block#) =
  3693.      (select u.file#, u.block# from undo$ u 
  3694.         where us# = 0);
  3695. update ts$ set inc# = (select inc# from sys.ts$ where name = 'SYSTEM')
  3696. where name = 'SYSTEM';
  3697. #^ connect (maint, internal)
  3698.  
  3699.